TEZ-3963. Possible InflaterInputStream leaked in TezCommonUtils and related classes...
authorJason Lowe <jlowe@apache.org>
Fri, 6 Jul 2018 21:53:57 +0000 (16:53 -0500)
committerJason Lowe <jlowe@apache.org>
Fri, 6 Jul 2018 21:53:57 +0000 (16:53 -0500)
tez-api/src/main/java/org/apache/tez/common/TezCommonUtils.java

index 9cb76d9..c8e8e02 100644 (file)
@@ -394,8 +394,9 @@ public class TezCommonUtils {
   @Private
   public static byte[] decompressByteStringToByteArray(ByteString byteString, Inflater inflater) throws IOException {
     inflater.reset();
-    return IOUtils.toByteArray(new InflaterInputStream(byteString.newInput(), inflater));
-
+    try (InflaterInputStream inflaterInputStream = new InflaterInputStream(byteString.newInput(), inflater)) {
+      return IOUtils.toByteArray(inflaterInputStream);
+    }
   }
 
   public static String getCredentialsInfo(Credentials credentials, String identifier) {