Revision: 10170
Author:   [email protected]
Date:     Tue May 10 03:27:54 2011
Log: See http://code.google.com/p/google-web-toolkit/issues/detail?id=6015

Log error instead of throwing when a generated unit cannot be transferred to a file, so that filenames exceeding file system limits don't make the whole build
fail).

Patch from tbroyer

http://gwt-code-reviews.appspot.com/1382801/

http://code.google.com/p/google-web-toolkit/source/detail?r=10170

Modified:
 /trunk/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java

=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java Tue Apr 26 08:02:24 2011 +++ /trunk/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java Tue May 10 03:27:54 2011
@@ -67,12 +67,12 @@
 public class StandardGeneratorContext implements GeneratorContextExt {

   /**
-   * Extras added to {@link CompilationUnit}.
+   * Extras added to {@link GeneratedUnit}.
    */
-  public static interface Generated extends GeneratedUnit {
+  private static interface Generated extends GeneratedUnit {
     void abort();

-    void commit();
+    void commit(TreeLogger logger);

     /**
      * Returns the strong hash of the source.
@@ -83,7 +83,7 @@
   }

   /**
- * This compilation unit acts as a normal compilation unit as well as a buffer + * This generated unit acts as a normal generated unit as well as a buffer * into which generators can write their source. A controller should ensure * that source isn't requested until the generator has finished writing it.
    * This version is backed by {@link StandardGeneratorContext#diskCache}.
@@ -113,9 +113,9 @@
     }

     /**
-     * Finalizes the source and adds this compilation unit to the host.
+     * Finalizes the source and adds this generated unit to the host.
      */
-    public void commit() {
+    public void commit(TreeLogger logger) {
       String source = sw.toString();
       strongHash = Util.computeStrongName(Util.getBytes(source));
       sourceToken = diskCache.writeString(source);
@@ -155,7 +155,7 @@
   }

   /**
- * This compilation unit acts as a normal compilation unit as well as a buffer + * This generated unit acts as a normal generated unit as well as a buffer * into which generators can write their source. A controller should ensure * that source isn't requested until the generator has finished writing it.
    * This version is backed by an explicit generated file.
@@ -169,15 +169,15 @@
     }

     @Override
-    public void commit() {
-      super.commit();
+    public void commit(TreeLogger logger) {
+      super.commit(logger);
       FileOutputStream fos = null;
       try {
         fos = new FileOutputStream(file);
         diskCache.transferToStream(sourceToken, fos);
       } catch (IOException e) {
-        throw new RuntimeException("Error writing out generated unit at '"
-            + file.getAbsolutePath() + "'", e);
+        logger.log(TreeLogger.WARN, "Error writing out generated unit at '"
+            + file.getAbsolutePath() + "': " + e);
       } finally {
         Utility.close(fos);
       }
@@ -185,7 +185,7 @@

     @Override
     public String optionalFileLocation() {
-      return file.getAbsolutePath();
+      return file.exists() ? file.getAbsolutePath() : null;
     }
   }

@@ -382,7 +382,7 @@
   public final void commit(TreeLogger logger, PrintWriter pw) {
     Generated gcup = uncommittedGeneratedCupsByPrintWriter.get(pw);
     if (gcup != null) {
-      gcup.commit();
+      gcup.commit(logger);
       uncommittedGeneratedCupsByPrintWriter.remove(pw);
       committedGeneratedCups.put(gcup.getTypeName(), gcup);
     } else {

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

Reply via email to