TEZ-3962. Configuration decode leaks an Inflater object (Eric Wohlstadter via jlowe)
authorJason Lowe <jlowe@apache.org>
Thu, 28 Jun 2018 21:13:02 +0000 (16:13 -0500)
committerJason Lowe <jlowe@apache.org>
Thu, 28 Jun 2018 21:13:02 +0000 (16:13 -0500)
tez-api/src/main/java/org/apache/tez/common/TezUtils.java

index efd4502..aed9e0f 100644 (file)
@@ -112,11 +112,12 @@ public class TezUtils {
     Preconditions.checkNotNull(byteString, "ByteString must be specified");
     // SnappyInputStream uncompressIs = new
     // SnappyInputStream(byteString.newInput());
-    InflaterInputStream uncompressIs = new InflaterInputStream(byteString.newInput());
-    DAGProtos.ConfigurationProto confProto = DAGProtos.ConfigurationProto.parseFrom(uncompressIs);
-    Configuration conf = new Configuration(false);
-    readConfFromPB(confProto, conf);
-    return conf;
+    try(InflaterInputStream uncompressIs = new InflaterInputStream(byteString.newInput())) {
+      DAGProtos.ConfigurationProto confProto = DAGProtos.ConfigurationProto.parseFrom(uncompressIs);
+      Configuration conf = new Configuration(false);
+      readConfFromPB(confProto, conf);
+      return conf;
+    }
   }
 
   /**