Reviewers: cromwellian,

Description:
Inflate and Deflate on writeObject


Please review this at http://gwt-code-reviews.appspot.com/1672803/

Affected files:
  M dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
  M dev/core/src/com/google/gwt/dev/util/DiskCache.java


Index: dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
===================================================================
--- dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java (revision 10920) +++ dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java (working copy)
@@ -157,6 +157,7 @@
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
+import java.util.zip.DeflaterOutputStream;
 import java.util.zip.GZIPInputStream;

 import javax.xml.parsers.ParserConfigurationException;
@@ -184,7 +185,9 @@
       this.permutation = permutation;
       try {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        Util.writeObjectToStream(baos, (Object) symbolMap);
+        DeflaterOutputStream dOut = new DeflaterOutputStream(baos);
+        Util.writeObjectToStream(dOut, (Object) symbolMap);
+        dOut.finish();
         this.serializedSymbolMap = baos.toByteArray();
       } catch (IOException e) {
throw new RuntimeException("Should never happen with in-memory stream", e);
Index: dev/core/src/com/google/gwt/dev/util/DiskCache.java
===================================================================
--- dev/core/src/com/google/gwt/dev/util/DiskCache.java (revision 10920)
+++ dev/core/src/com/google/gwt/dev/util/DiskCache.java (working copy)
@@ -25,6 +25,9 @@
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.zip.DeflaterOutputStream;
+import java.util.zip.InflaterInputStream;
+import java.util.zip.InflaterOutputStream;

 /**
  * A nifty class that lets you squirrel away data on the file system. Write
@@ -118,7 +121,8 @@
     try {
       byte[] bytes = readByteArray(token);
       ByteArrayInputStream in = new ByteArrayInputStream(bytes);
-      return Util.readStreamAsObject(in, type);
+      InflaterInputStream dIn = new InflaterInputStream(in);
+      return Util.readStreamAsObject(dIn, type);
     } catch (ClassNotFoundException e) {
throw new RuntimeException("Unexpected exception deserializing from disk cache", e);
     } catch (IOException e) {
@@ -228,7 +232,9 @@
   public long writeObject(Object object) {
     try {
       ByteArrayOutputStream out = new ByteArrayOutputStream();
-      Util.writeObjectToStream(out, object);
+      DeflaterOutputStream dOut = new DeflaterOutputStream(out);
+      Util.writeObjectToStream(dOut, object);
+      dOut.finish();
       return writeByteArray(out.toByteArray());
     } catch (IOException e) {
throw new RuntimeException("Unexpected IOException on in-memory stream", e);
@@ -275,4 +281,4 @@
       return position;
     }
   }
-}
\ No newline at end of file
+}


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to