Ensure that MhtmlClientBundleGenerator#createResourceContext generates unique strong names.
Patch by: jlabanca
Review by: bobv
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6517 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/resources/rebind/context/MhtmlClientBundleGenerator.java b/user/src/com/google/gwt/resources/rebind/context/MhtmlClientBundleGenerator.java
index 4ca979a..984b42d 100644
--- a/user/src/com/google/gwt/resources/rebind/context/MhtmlClientBundleGenerator.java
+++ b/user/src/com/google/gwt/resources/rebind/context/MhtmlClientBundleGenerator.java
@@ -31,6 +31,7 @@
public class MhtmlClientBundleGenerator extends AbstractClientBundleGenerator {
private static final String BUNDLE_EXTENSION = ".cache.txt";
+ private static int counter = 0;
private MhtmlResourceContext resourceContext;
private String partialPath;
@@ -42,10 +43,15 @@
resourceBundleType);
/*
+ * We use a counter to ensure that the generated resources have unique
+ * names. Previously we used the system time, but it sometimes led to non-
+ * unique names if subsequent calls happened within the same millisecond.
+ *
* TODO: figure out how to make the filename stable based on actual content.
*/
+ counter++;
partialPath = Util.computeStrongName(Util.getBytes(resourceBundleType.getQualifiedSourceName()
- + System.currentTimeMillis()))
+ + counter))
+ BUNDLE_EXTENSION;
resourceContext.setPartialPath(partialPath);