On Tue, Oct 28, 2008 at 6:07 AM, stuckagain <[EMAIL PROTECTED]> wrote:

> Now that I am migrating to 1.5, I noticed this bug for example: (one
> that I reported some time ago):
> http://code.google.com/p/google-web-toolkit/issues/detail?id=2257&can=4
>
> It is marked as new, and targeted for 1.5_RC ... can I assume that
> this is now fixed in 1.5.3 ? I guess not ?
> There are many other bugs that seem to be completely forgotten as
> well.
>

Please review the attached patch for issue 2257.  After talking with Miguel,
we decided to only consider the contents of the file in the hash rather than
using a fixed line terminator which may pose issues for limited editors on
Windows.

The patch is relative to trunk @ r3879, but I would propose this go into
1.6.

-- 
John A. Tamplin
Software Engineer (GWT), Google

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

Index: dev/core/src/com/google/gwt/dev/util/Util.java
===================================================================
--- dev/core/src/com/google/gwt/dev/util/Util.java	(revision 3879)
+++ dev/core/src/com/google/gwt/dev/util/Util.java	(working copy)
@@ -132,13 +132,7 @@
    *         formatted for use as a file name
    */
   public static String computeStrongName(byte[] content) {
-    MessageDigest md5;
-    try {
-      md5 = MessageDigest.getInstance("MD5");
-    } catch (NoSuchAlgorithmException e) {
-      throw new RuntimeException("Error initializing MD5", e);
-    }
-
+    MessageDigest md5 = getMd5Digest();
     md5.update(content);
     return toHexString(md5.digest());
   }
@@ -325,6 +319,20 @@
   }
 
   /**
+   * @return an MD5 MessageDigest instance
+   * @throws RuntimeException if MD5 isn't available
+   */
+  public static MessageDigest getMd5Digest() {
+    MessageDigest md5;
+    try {
+      md5 = MessageDigest.getInstance("MD5");
+    } catch (NoSuchAlgorithmException e) {
+      throw new RuntimeException("Error initializing MD5", e);
+    }
+    return md5;
+  }
+
+  /**
    * A 4-digit hex result.
    */
   public static void hex4(char c, StringBuffer sb) {
Index: user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
===================================================================
--- user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java	(revision 3879)
+++ user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java	(working copy)
@@ -49,6 +49,7 @@
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -539,19 +540,22 @@
       PrintWriter pw = new PrintWriter(osw);
 
       JType[] serializableTypes = sto.getSerializableTypes();
+      MessageDigest md5 = Util.getMd5Digest();
       for (int i = 0; i < serializableTypes.length; ++i) {
         JType serializableType = serializableTypes[i];
         String binaryTypeName = sto.getSerializedTypeName(serializableType);
         boolean maybeInstantiated = sto.maybeInstantiated(serializableType);
-        pw.println(binaryTypeName + ", " + Boolean.toString(maybeInstantiated));
+        String line = binaryTypeName + ", "
+            + Boolean.toString(maybeInstantiated);
+        md5.update(line.getBytes(SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING));
+        pw.println(line);
       }
 
       // Closes the wrapped streams.
       pw.close();
 
       byte[] serializationPolicyFileContents = baos.toByteArray();
-      String serializationPolicyName = Util.computeStrongName(serializationPolicyFileContents);
-
+      String serializationPolicyName = Util.toHexString(md5.digest());
       String serializationPolicyFileName = SerializationPolicyLoader.getSerializationPolicyFileName(serializationPolicyName);
       OutputStream os = ctx.tryCreateResource(logger,
           serializationPolicyFileName);

Reply via email to