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

java.lang.UnsupportedOperationException in RecordIssuesStep

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • workflow-api 2.41

      While recording ideaInspection, we get the following exception:

      java.lang.UnsupportedOperationException
      	at java.util.concurrent.CopyOnWriteArrayList$COWIterator.remove(CopyOnWriteArrayList.java:1182)
      	at java.util.AbstractCollection.removeAll(AbstractCollection.java:376)
      	at hudson.model.Actionable.addOrReplaceAction(Actionable.java:209)
      	at io.jenkins.plugins.analysis.core.util.PipelineResultHandler.setResult(PipelineResultHandler.java:34)
      	at io.jenkins.plugins.analysis.core.steps.IssuesPublisher.attachAction(IssuesPublisher.java:120)
      	at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.publishResult(IssuesRecorder.java:721)
      	at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.record(IssuesRecorder.java:651)
      	at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.perform(IssuesRecorder.java:617)
      	at io.jenkins.plugins.analysis.core.steps.RecordIssuesStep$Execution.run(RecordIssuesStep.java:1024)
      	at io.jenkins.plugins.analysis.core.steps.RecordIssuesStep$Execution.run(RecordIssuesStep.java:985)
      	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      

      The pipeline code:

      recordIssues(
      	failOnError: true,
      	enabledForFailure: true,
      	ignoreFailedBuilds: false,
      	qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]],
      	tools: [
      		ideaInspection(pattern: 'idea-inspection-output/**'),
      	],
      )
      

      This is identical in all projects. It is not related to the specific inspection result itself, as long as a failing inspection is reported. Projects without inspection errors will be a success.

      Please find attached a minimal example. Disabling failOnError will make the sample running. The only errors I see in my logs are:

      [IntelliJ IDEA Inspections] [-ERROR-] Can't create fingerprints for some files:
      [IntelliJ IDEA Inspections] [-ERROR-] - '$PROJECT_DIR$/testsrc/com/example/ExampleTest.java', IO exception has been thrown: java.nio.file.NoSuchFileException: $PROJECT_DIR$/testsrc/com/example/ExampleTest.java
      

      I'm not sure if this is related to the exception, but even if this is handled as an error in the sense of failOnError, there should be no exception.

          [JENKINS-64438] java.lang.UnsupportedOperationException in RecordIssuesStep

          Ulli Hafner added a comment -

          mheinzerling Which JRE are you using to run Jenkins?

          Ulli Hafner added a comment - mheinzerling Which JRE are you using to run Jenkins?

          Martin Heinzerling added a comment - - edited

          drulli, I updated the environment field.

          openjdk version "1.8.0_272"
          OpenJDK Runtime Environment (build 1.8.0_272-8u272-b10-0+deb9u1-b10)
          OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)
          

          Martin Heinzerling added a comment - - edited drulli , I updated the environment field. openjdk version "1.8.0_272" OpenJDK Runtime Environment (build 1.8.0_272-8u272-b10-0+deb9u1-b10) OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)

          Fixing the inspection result with the snippet below before recordIssues fixed the issue for me:

          sh "sed -i -- 's@\\\$PROJECT_DIR\\\$@"+env.WORKSPACE+"@g' idea-inspection-output/*.xml"
          

          Nevertheless the root issue is not addressed by my fix.

          Martin Heinzerling added a comment - Fixing the inspection result with the snippet below before recordIssues fixed the issue for me: sh "sed -i -- 's@\\\$PROJECT_DIR\\\$@" +env.WORKSPACE+ "@g' idea-inspection-output/*.xml" Nevertheless the root issue is not addressed by my fix.

          Ulli Hafner added a comment -

          Hmm, the exception actually is unrelated to the workspace path fix. 

          Ulli Hafner added a comment - Hmm, the exception actually is unrelated to the workspace path fix. 

          I know, but this is satisfying the error in "failOnError=true" and the build is no longer taking this branch of code.

          Martin Heinzerling added a comment - I know, but this is satisfying the error in "failOnError=true" and the build is no longer taking this branch of code.

          Daniel Beck added a comment -

          This looks as if the CopyOnWriteArrayList did not implement removeAll and the fallback implementation using iterator fails (as documented, COWIterator#remove doesn't work).

          But that removeAll implementation in CopyOnWriteArrayList has been around forever…

          Daniel Beck added a comment - This looks as if the  CopyOnWriteArrayList did not implement removeAll and the fallback implementation using iterator fails (as documented, COWIterator#remove doesn't work). But that removeAll implementation in CopyOnWriteArrayList has been around forever…

          Devin Nusbaum added a comment -

          Replied on the mailing list as well, but I think the problem is that the implementation of FlowNode.getActions returns an anonymous implementation of AbstractList that needs to override removeAll for Actionable.addOrReplaceAction to work correctly when replacing an existing Action.

          Devin Nusbaum added a comment - Replied on the mailing list as well, but I think the problem is that the implementation of FlowNode.getActions returns an anonymous implementation of AbstractList that needs to override removeAll for Actionable.addOrReplaceAction to work correctly when replacing an existing Action .

          Ulli Hafner added a comment -

          dnusbaum Thanks for spotting it! I'll add workflow-api as component here in Jira.

          Ulli Hafner added a comment - dnusbaum Thanks for spotting it! I'll add workflow-api as component here in Jira.

          Devin Nusbaum added a comment -

          Fixed in https://github.com/jenkinsci/workflow-api-plugin/pull/133 by mrginglymus. Thanks! The fix has been merged but it has not yet been released.

          Devin Nusbaum added a comment - Fixed in https://github.com/jenkinsci/workflow-api-plugin/pull/133 by mrginglymus . Thanks! The fix has been merged but it has not yet been released.

          Devin Nusbaum added a comment -

          This was fixed in Pipeline: API plugin version 2.41. Thanks mrginglymus!

          Devin Nusbaum added a comment - This was fixed in Pipeline: API plugin version 2.41. Thanks mrginglymus !

            mrginglymus Bill Collins
            mheinzerling Martin Heinzerling
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: