8065769: OOM on Window/Solaris in test compile-octane-splitter.js
authorhannesw
Wed, 03 Dec 2014 14:49:36 +0100
changeset 27821 87ac5547bbf3
parent 27820 cd39dfeab986
child 27822 a3866b9fb44d
8065769: OOM on Window/Solaris in test compile-octane-splitter.js Reviewed-by: sundar, jlaskey
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AstSerializer.java
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AstSerializer.java	Wed Dec 03 11:43:57 2014 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AstSerializer.java	Wed Dec 03 14:49:36 2014 +0100
@@ -48,11 +48,13 @@
     private static final int COMPRESSION_LEVEL = Options.getIntProperty("nashorn.serialize.compression", 4);
     static byte[] serialize(final FunctionNode fn) {
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
-        try (final ObjectOutputStream oout = new ObjectOutputStream(new DeflaterOutputStream(out,
-                new Deflater(COMPRESSION_LEVEL)))) {
+        final Deflater deflater = new Deflater(COMPRESSION_LEVEL);
+        try (final ObjectOutputStream oout = new ObjectOutputStream(new DeflaterOutputStream(out, deflater))) {
             oout.writeObject(removeInnerFunctionBodies(fn));
         } catch (final IOException e) {
             throw new AssertionError("Unexpected exception serializing function", e);
+        } finally {
+            deflater.end();
         }
         return out.toByteArray();
     }