Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-11739

Mysterious FilerException: Attempt to reopen a file for path ...

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Similar Issues:

      Description

      There was a report indicating that a compilation error happens while building Jenkins:

      [INFO] Copying 2 resources
      [INFO] [stapler:apt-compile {execution: default-apt-compile}]
      [INFO] Compiling 721 source files to /«PKGBUILDDIR»/core/target/classes
      [INFO]
      - ------------------------------------------------------------------------
      [ERROR] BUILD FAILURE
      [INFO]
      - ------------------------------------------------------------------------
      [INFO] Compilation failure
      
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path TemporarySpaceMonitor.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path CommandConnector.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path BuildButtonColumn.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path LastSuccessColumn.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path ListView.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path MavenInstallation.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path MavenInstaller.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path Maven.stapler
      error: javax.annotation.processing.FilerException: Attempt to reopen a file for path AbstractDiskSpaceMonitor.stapler
      

      To the best of my understanding, this can only happen if our annotation processors are invoked twice with the same set of root elements, and if I'm reading it right, with JSR-269 this cannot happen.

      Since blaming JSR-269 implementation will likely take years to resolve, I'm going ahead to work around this on our side. But to make sure that I'm not mis-interpreting JSR-269 or that there's something more deeper, I'm creating this ticket to solicit feedbacks from people.

        Attachments

          Activity

          kohsuke Kohsuke Kawaguchi created issue -
          Hide
          kohsuke Kohsuke Kawaguchi added a comment -

          I've worked around this problem in Stapler 1.175 by simply ignoring this problem. But the error message points people to this ticket.

          Folks, if you see the message and come here, please report your exact JDK version, and verify if you continue to see the problem after a clean rebuild.

          Show
          kohsuke Kohsuke Kawaguchi added a comment - I've worked around this problem in Stapler 1.175 by simply ignoring this problem. But the error message points people to this ticket. Folks, if you see the message and come here, please report your exact JDK version, and verify if you continue to see the problem after a clean rebuild.
          kohsuke Kohsuke Kawaguchi made changes -
          Field Original Value New Value
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Hide
          kohsuke Kohsuke Kawaguchi added a comment -

          James Page found out that the root cause of this is old Jenkins core + new stapler combination, which causes both APT annotation processor and JSR-269 annotation processor to run.

          Show
          kohsuke Kohsuke Kawaguchi added a comment - James Page found out that the root cause of this is old Jenkins core + new stapler combination, which causes both APT annotation processor and JSR-269 annotation processor to run.
          Hide
          stephenconnolly Stephen Connolly added a comment -

          Actually, even with the correct matching versions, you can have this issue on

          Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
          Java version: 1.6.0_29, vendor: Apple Inc.
          Default locale: en_US, platform encoding: MacRoman
          OS name: "mac os x", version: "10.6.8", arch: "x86_64", family: "mac"

          at least.

          To reproduce, just put a package-info.java file in any directory with a @DataBoundConstructor

          Workaround to fix:

          remove the package-info.java file

          Happens with

          hpi 1.78 & stapler 1.16 (current head circa 1.449)
          hpi 1.74 & stapler 1.15 (1.424 LTS)
          hpi 1.71 & stapler 1.15 (1.409 LTS)

          Show
          stephenconnolly Stephen Connolly added a comment - Actually, even with the correct matching versions, you can have this issue on Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000) Java version: 1.6.0_29, vendor: Apple Inc. Default locale: en_US, platform encoding: MacRoman OS name: "mac os x", version: "10.6.8", arch: "x86_64", family: "mac" at least. To reproduce, just put a package-info.java file in any directory with a @DataBoundConstructor Workaround to fix: remove the package-info.java file Happens with hpi 1.78 & stapler 1.16 (current head circa 1.449) hpi 1.74 & stapler 1.15 (1.424 LTS) hpi 1.71 & stapler 1.15 (1.409 LTS)
          stephenconnolly Stephen Connolly made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          jglick Jesse Glick added a comment -

          Same happens (but with no workaround) in 1.466.1 when processing Plugin declarations, just running javac (i.e. APT is not to blame):

          at com.sun.tools.javac.processing.JavacFiler.checkFileReopening(JavacFiler.java:535)
          at com.sun.tools.javac.processing.JavacFiler.createResource(JavacFiler.java:431)
          at jenkins.PluginSubtypeMarker.write(PluginSubtypeMarker.java:99)
          at jenkins.PluginSubtypeMarker.access$100(PluginSubtypeMarker.java:60)
          at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:71)
          at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:64)
          at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:892)
          at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141)
          at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:131)
          at javax.lang.model.util.ElementScanner6.visitPackage(ElementScanner6.java:160)
          at com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:692)
          at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141)
          at jenkins.PluginSubtypeMarker.process(PluginSubtypeMarker.java:85)
          
          Show
          jglick Jesse Glick added a comment - Same happens (but with no workaround) in 1.466.1 when processing Plugin declarations, just running javac (i.e. APT is not to blame): at com.sun.tools.javac.processing.JavacFiler.checkFileReopening(JavacFiler.java:535) at com.sun.tools.javac.processing.JavacFiler.createResource(JavacFiler.java:431) at jenkins.PluginSubtypeMarker.write(PluginSubtypeMarker.java:99) at jenkins.PluginSubtypeMarker.access$100(PluginSubtypeMarker.java:60) at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:71) at jenkins.PluginSubtypeMarker$1.visitType(PluginSubtypeMarker.java:64) at com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:892) at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141) at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:131) at javax.lang.model.util.ElementScanner6.visitPackage(ElementScanner6.java:160) at com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:692) at javax.lang.model.util.ElementScanner6.scan(ElementScanner6.java:141) at jenkins.PluginSubtypeMarker.process(PluginSubtypeMarker.java:85)
          Hide
          jglick Jesse Glick added a comment -

          The processor is not really written correctly; the right way to write processors which generate an index is to read the existing file, if any, queue up writes while !processingOver, then when processingOver perform them (unless errorRaised). org.openide.util.lookup.implspi.AbstractServiceProviderProcessor is an example. But the immediate bug is triggered, as Stephen found, by package-info.java since you are incorrectly scanning package elements.

          Show
          jglick Jesse Glick added a comment - The processor is not really written correctly; the right way to write processors which generate an index is to read the existing file, if any, queue up writes while !processingOver , then when processingOver perform them (unless errorRaised ). org.openide.util.lookup.implspi.AbstractServiceProviderProcessor is an example. But the immediate bug is triggered, as Stephen found, by package-info.java since you are incorrectly scanning package elements.
          jglick Jesse Glick made changes -
          Assignee Kohsuke Kawaguchi [ kohsuke ] jglick [ jglick ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/jenkins/PluginSubtypeMarker.java
          http://jenkins-ci.org/commit/jenkins/88b613e95f6d8991a047f13275179e190e4c7587
          Log:
          JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java.
          (Not quite FIXED yet since org.kohsuke.stapler.jsr269 seems to suffer from a similar bug, currently printing ugly warnings.)

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/jenkins/PluginSubtypeMarker.java http://jenkins-ci.org/commit/jenkins/88b613e95f6d8991a047f13275179e190e4c7587 Log: JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java. (Not quite FIXED yet since org.kohsuke.stapler.jsr269 seems to suffer from a similar bug, currently printing ugly warnings.)
          Hide
          dogfood dogfood added a comment -

          Integrated in jenkins_main_trunk #1829
          JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java. (Revision 88b613e95f6d8991a047f13275179e190e4c7587)

          Result = UNSTABLE
          Jesse Glick : 88b613e95f6d8991a047f13275179e190e4c7587
          Files :

          • core/src/main/java/jenkins/PluginSubtypeMarker.java
          Show
          dogfood dogfood added a comment - Integrated in jenkins_main_trunk #1829 JENKINS-11739 Cannot compile a plugin with a Plugin subclass in the same package as a package-info.java. (Revision 88b613e95f6d8991a047f13275179e190e4c7587) Result = UNSTABLE Jesse Glick : 88b613e95f6d8991a047f13275179e190e4c7587 Files : core/src/main/java/jenkins/PluginSubtypeMarker.java
          Hide
          jglick Jesse Glick added a comment -

          Final fix is in Stapler, but I did not manage to release it.

          Show
          jglick Jesse Glick added a comment - Final fix is in Stapler, but I did not manage to release it.
          jglick Jesse Glick made changes -
          Assignee jglick [ jglick ] Kohsuke Kawaguchi [ kohsuke ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Jesse Glick
          Path:
          changelog.html
          core/pom.xml
          war/pom.xml
          http://jenkins-ci.org/commit/jenkins/10dddebf7bd86e30b630038e5ebe0295f190a8de
          Log:
          [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: changelog.html core/pom.xml war/pom.xml http://jenkins-ci.org/commit/jenkins/10dddebf7bd86e30b630038e5ebe0295f190a8de Log: [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins.
          scm_issue_link SCM/JIRA link daemon made changes -
          Resolution Fixed [ 1 ]
          Status Reopened [ 4 ] Resolved [ 5 ]
          Hide
          dogfood dogfood added a comment -

          Integrated in jenkins_main_trunk #1836
          [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins. (Revision 10dddebf7bd86e30b630038e5ebe0295f190a8de)

          Result = UNSTABLE
          Jesse Glick : 10dddebf7bd86e30b630038e5ebe0295f190a8de
          Files :

          • core/pom.xml
          • changelog.html
          • war/pom.xml
          Show
          dogfood dogfood added a comment - Integrated in jenkins_main_trunk #1836 [FIXED JENKINS-11739] Various mistakes in annotation processors affecting some plugins. (Revision 10dddebf7bd86e30b630038e5ebe0295f190a8de) Result = UNSTABLE Jesse Glick : 10dddebf7bd86e30b630038e5ebe0295f190a8de Files : core/pom.xml changelog.html war/pom.xml
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 141982 ] JNJira + In-Review [ 189920 ]

            People

            Assignee:
            kohsuke Kohsuke Kawaguchi
            Reporter:
            kohsuke Kohsuke Kawaguchi
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: