Revision: 3daeffb7a665
Author:   Rick Shaw <wfs...@gmail.com>
Date:     Tue Apr 24 07:10:09 2012
Log:      Resolve issue #28. Call the end() method of Deflator in a finally
clause.

The deflator was allocating some system memory for the deflation process
but was never giving it back upon closing the structure. The docs say it
will be cleaned up by the finalizer but that did not seem to be the
case. It needed to be closed explicitly
http://code.google.com/a/apache-extras.org/p/cassandra-jdbc/source/detail?r=3daeffb7a665

Modified:
 /src/main/java/org/apache/cassandra/cql/jdbc/Utils.java

=======================================
--- /src/main/java/org/apache/cassandra/cql/jdbc/Utils.java Thu Oct 13 00:45:22 2011 +++ /src/main/java/org/apache/cassandra/cql/jdbc/Utils.java Tue Apr 24 07:10:09 2012
@@ -114,10 +114,17 @@
         ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
         byte[] buffer = new byte[1024];

-        while (!compressor.finished())
-        {
-            int size = compressor.deflate(buffer);
-            byteArray.write(buffer, 0, size);
+        try
+        {
+            while (!compressor.finished())
+            {
+                int size = compressor.deflate(buffer);
+                byteArray.write(buffer, 0, size);
+            }
+        }
+        finally
+        {
+            compressor.end(); //clean up after the Deflater
         }

logger.trace("Compressed query statement {} bytes in length to {} bytes", data.length, byteArray.size());

Reply via email to