changeset 9692:cacad86dccd0

8038431: Close InputStream when finished retrieving XML Signature HTTP References Reviewed-by: xuelei
author mullan
date Tue, 08 Apr 2014 11:57:57 -0400
parents e6d4d07dee4c
children 656a8718f0d3
files src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java	Mon Apr 07 15:40:05 2014 +0100
+++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java	Tue Apr 08 11:57:57 2014 -0400
@@ -108,6 +108,7 @@
     @Override
     public XMLSignatureInput engineResolveURI(ResourceResolverContext context)
         throws ResourceResolverException {
+        InputStream inputStream = null;
         try {
 
             // calculate new URI
@@ -139,7 +140,7 @@
             }
 
             String mimeType = urlConnection.getHeaderField("Content-Type");
-            InputStream inputStream = urlConnection.getInputStream();
+            inputStream = urlConnection.getInputStream();
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             byte buf[] = new byte[4096];
             int read = 0;
@@ -168,6 +169,16 @@
             throw new ResourceResolverException("generic.EmptyMessage", ex, context.attr, context.baseUri);
         } catch (IllegalArgumentException e) {
             throw new ResourceResolverException("generic.EmptyMessage", e, context.attr, context.baseUri);
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    if (log.isLoggable(java.util.logging.Level.FINE)) {
+                        log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+                    }
+                }
+            }
         }
     }