You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by lm...@apache.org on 2018/08/30 23:12:49 UTC

knox git commit: KNOX-1430 - Potential output stream handle leak when copyLarge files in streamResponse (Guang Yang via lmccay)

Repository: knox
Updated Branches:
  refs/heads/master bc0cca6e5 -> 18bd3b8e2


KNOX-1430 - Potential output stream handle leak when copyLarge files in streamResponse (Guang Yang via lmccay)

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/18bd3b8e
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/18bd3b8e
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/18bd3b8e

Branch: refs/heads/master
Commit: 18bd3b8e279bd4a7c93a1808feee34e5f9a13900
Parents: bc0cca6
Author: Larry McCay <la...@oracle.com>
Authored: Thu Aug 30 18:45:20 2018 -0400
Committer: Larry McCay <la...@oracle.com>
Committed: Thu Aug 30 18:45:20 2018 -0400

----------------------------------------------------------------------
 .../gateway/filter/rewrite/impl/UrlRewriteResponse.java     | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/18bd3b8e/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
index d451c26..d623079 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/knox/gateway/filter/rewrite/impl/UrlRewriteResponse.java
@@ -181,9 +181,12 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements Params
     InputStream filteredInput = UrlRewriteStreamFilterFactory.create(
         mimeType, null, inStream, rewriter, this, UrlRewriter.Direction.OUT, filterContentConfig );
     outStream = (isGzip) ? new GZIPOutputStream(output) : output;
-    IOUtils.copyLarge( filteredInput, outStream, new byte[STREAM_BUFFER_SIZE] );
-    //KNOX-685: outStream.flush();
-    outStream.close();
+    try {
+        IOUtils.copyLarge( filteredInput, outStream, new byte[STREAM_BUFFER_SIZE] );
+    } finally {
+        //KNOX-685: outStream.flush();
+        outStream.close();
+    }
   }
 
   //TODO: Need to buffer the output here and when it is closed, rewrite it and then write the result to the stream.