Reviewers: bobv,

Message:
We've been running with this patch for 6 weeks or so and it's highly
misleading to have it logged as an error with a full stack-trace.
I'll update the patch to log a warning instead (or maybe only an info?)
and only include the exception's getLocalizedMessage (or toString) in
the message, without passing the exception to the logger so we don't
have the stack trace printed out (which doesn't help anyway).

Here's a sample output from our Jenkins CI server (thus, the [INFO]
prefix comes from Maven) so you get an idea of how much it "pollutes"
the output (we have a dozen of these):
[INFO]             Invoking generator
com.google.gwt.requestfactory.rebind.RequestFactoryEditorDriverGenerator
[INFO]                [ERROR] Error writing out generated unit at
'<snipped really long name>'
[INFO] java.io.FileNotFoundException: <snipped really long name> (File
name too long)
[INFO]  at java.io.FileOutputStream.open(Native Method)
[INFO]  at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
[INFO]  at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
[INFO]  at
com.google.gwt.dev.javac.StandardGeneratorContext$GeneratedUnitWithFile.commit(StandardGeneratorContext.java:176)
[INFO]  at
com.google.gwt.dev.javac.StandardGeneratorContext.commit(StandardGeneratorContext.java:385)
[INFO]  at
com.google.gwt.user.rebind.ClassSourceFileComposer.commit(ClassSourceFileComposer.java:107)
[INFO]  at
com.google.gwt.editor.rebind.AbstractEditorDriverGenerator.getEditorDelegate(AbstractEditorDriverGenerator.java:201)
[INFO]  at
com.google.gwt.editor.rebind.AbstractEditorDriverGenerator.getEditorDelegate(AbstractEditorDriverGenerator.java:159)
[INFO]  at
com.google.gwt.editor.rebind.AbstractEditorDriverGenerator.getEditorDelegate(AbstractEditorDriverGenerator.java:159)
[INFO]  at
com.google.gwt.editor.rebind.AbstractEditorDriverGenerator.writeCreateDelegate(AbstractEditorDriverGenerator.java:311)
[INFO]  at
com.google.gwt.editor.rebind.AbstractEditorDriverGenerator.generate(AbstractEditorDriverGenerator.java:80)
[INFO]  at
com.google.gwt.requestfactory.rebind.RequestFactoryEditorDriverGenerator.generate(RequestFactoryEditorDriverGenerator.java:42)
[INFO]  at
com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
[INFO]  at
com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
[INFO]  at
com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:681)
[INFO]  at
com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
[INFO]  at
com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:74)
[INFO]  at
com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:259)
[INFO]  at
com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:248)
[INFO]  at
com.google.gwt.dev.DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(DistillerRebindPermutationOracle.java:91)
[INFO]  at
com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.doFindAdditionalTypesUsingRebinds(WebModeCompilerFrontEnd.java:106)
[INFO]  at
com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.process(AbstractCompiler.java:251)
[INFO]  at
org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
[INFO]  at
com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:170)
[INFO]  at
com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.compile(AbstractCompiler.java:285)
[INFO]  at
com.google.gwt.dev.jdt.AbstractCompiler$Sandbox$CompilerImpl.access$400(AbstractCompiler.java:139)
[INFO]  at
com.google.gwt.dev.jdt.AbstractCompiler.compile(AbstractCompiler.java:587)
[INFO]  at
com.google.gwt.dev.jdt.BasicWebModeCompiler.getCompilationUnitDeclarations(BasicWebModeCompiler.java:124)
[INFO]  at
com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.getCompilationUnitDeclarations(WebModeCompilerFrontEnd.java:54)
[INFO]  at
com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:525)
[INFO]  at
com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:35)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:541)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:495)
[INFO]  at com.google.gwt.dev.Precompile.precompile(Precompile.java:407)
[INFO]  at com.google.gwt.dev.Compiler.run(Compiler.java:215)
[INFO]  at com.google.gwt.dev.Compiler.run(Compiler.java:187)
[INFO]  at com.google.gwt.dev.Compiler$1.run(Compiler.java:159)
[INFO]  at
com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:87)
[INFO]  at
com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:81)
[INFO]  at com.google.gwt.dev.Compiler.main(Compiler.java:166)

Description:
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).

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

Affected files:
  M dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java


Index: dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
diff --git a/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java b/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java index 0b2e301561ae9b82f8a6ca3239fdadb60ee02eae..6effbb0142c84e87b96391f5be6557a1cce167bc 100644
--- a/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
+++ b/dev/core/src/com/google/gwt/dev/javac/StandardGeneratorContext.java
@@ -67,12 +67,12 @@ import java.util.SortedSet;
 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 @@ public class StandardGeneratorContext implements GeneratorContextExt {
   }

   /**
- * 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 @@ public class StandardGeneratorContext implements GeneratorContextExt {
     }

     /**
-     * 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));
       cacheToken = diskCache.writeString(source);
@@ -148,7 +148,7 @@ public class StandardGeneratorContext implements GeneratorContextExt {
   }

   /**
- * 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.
@@ -162,14 +162,14 @@ public class StandardGeneratorContext implements GeneratorContextExt {
     }

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

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

@@ -374,7 +374,7 @@ public class StandardGeneratorContext implements GeneratorContextExt {
   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