Reviewers: jbrosenberg,

Message:
if you build in ant from a clean build, you'll see an NPE in DiskCache.
My testing before my last change didn't include cleaning out the old
.gwtar files, so all the units being written were
CachedCompilationUnits.


http://gwt-code-reviews.appspot.com/1461803/diff/1/dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java
File
dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java
(right):

http://gwt-code-reviews.appspot.com/1461803/diff/1/dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java#newcode60
dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java:60:
sourceToken = diskCache.writeString(sourceCode);
this is copied from getSource().  You would think it would make sense to
share code, but getSource() is on the chopping block and will be removed
soon.

Description:
Bug triggered when SourceFileCompilationUnit.asCachedCompilation() unit
was called before source was read for the first time.


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

Affected files:
  M dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java
  M dev/core/src/com/google/gwt/dev/util/DiskCache.java


Index: dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java
===================================================================
--- dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java (revision 10389) +++ dev/core/src/com/google/gwt/dev/javac/SourceFileCompilationUnit.java (working copy)
@@ -56,7 +56,8 @@
   @Override
   public CachedCompilationUnit asCachedCompilationUnit() {
     if (sourceToken < 0) {
- sourceToken = diskCache.transferFromStream(sourceFile.openContents());
+      String sourceCode = Shared.readSource(sourceFile);
+      sourceToken = diskCache.writeString(sourceCode);
     }
     return new CachedCompilationUnit(this, sourceToken, astToken);
   }
Index: dev/core/src/com/google/gwt/dev/util/DiskCache.java
===================================================================
--- dev/core/src/com/google/gwt/dev/util/DiskCache.java (revision 10389)
+++ dev/core/src/com/google/gwt/dev/util/DiskCache.java (working copy)
@@ -141,6 +141,7 @@
    * @return a token to retrieve the data later
    */
   public synchronized long transferFromStream(InputStream in) {
+    assert in != null;
     byte[] buf = Util.takeThreadLocalBuf();
     try {
       long position = moveToEndPosition();


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

Reply via email to