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

Serialization of java.util.concurrent data structure in Pipeline: Groovy

XMLWordPrintable

    • 2683.vd0a_8f6a_1c263

      Steps to reproduce

      On Java 17, run mvn clean verify Dtest=org.jenkinsci.plugins.workflow.cps.CpsBodyExecutionTest,org.jenkinsci.plugins.workflow.cps.CpsThreadDumpActionTest -Djenkins.version=2.339 -Denforcer.skip -Djenkins-test-harness.version=1723.vcd938b_e66072 '-DargLine=-add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED'

      Expected results

      Note: These are the actual results when adding --add-opens java.base/java.util.concurrent=ALL-UNNAMED to the above arguments:

      The test passes.

      Actual results

      The test fails with:

      com.thoughtworks.xstream.converters.ConversionException: 
      No converter available
      ---- Debugging information ----
      message             : No converter available
      type                : java.util.concurrent.ConcurrentSkipListMap
      converter           : com.thoughtworks.xstream.converters.reflection.SerializableConverter
      message[1]          : Unable to make private void java.util.concurrent.ConcurrentSkipListMap.readObject(java.io.ObjectInputStream) throws java.io.IOException,java.lang.ClassNotFoundException accessible: module java.base does not "opens java.util.concurrent" to unnamed module @210366b4
      converter[1]        : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
      message[2]          : Unable to make field private static final long java.util.concurrent.ConcurrentSkipListMap.serialVersionUID accessible: module java.base does not "opens java.util.concurrent" to unnamed module @210366b4
      -------------------------------
      	at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:88)
      	at com.thoughtworks.xstream.XStream$1.lookupConverterForType(XStream.java:478)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:49)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:83)
      	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshallField(AbstractReflectionConverter.java:270)
      	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$2.writeField(AbstractReflectionConverter.java:174)
      	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doMarshal(AbstractReflectionConverter.java:262)
      	at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.marshal(AbstractReflectionConverter.java:90)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:68)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44)
      	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:83)
      	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1266)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1255)
      	at com.thoughtworks.xstream.XStream.toXML(XStream.java:1228)
      	at com.thoughtworks.xstream.XStream.toXML(XStream.java:1215)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.asXml(CpsThreadGroup.java:611)
      	at org.jenkinsci.plugins.workflow.cps.CpsBodyExecutionTest.lambda$closureCapturesCpsBodyExecution$4(CpsBodyExecutionTest.java:241)
      	at org.jvnet.hudson.test.RestartableJenkinsRule$3.evaluate(RestartableJenkinsRule.java:243)
      	at org.jvnet.hudson.test.RestartableJenkinsRule$6.evaluate(RestartableJenkinsRule.java:291)
      	at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:606)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
      	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.lang.Thread.run(Thread.java:833)
      

      Notes

      Of the core test suite and plugin BOM test suite, this is the only test failure I found with a java.util.concurrent reflection error. I think it would be desirable to eliminate java.util.concurrent from our Add-Opens directives if possible, since in most cases it is not necessary to serialize a concurrent data structure.

      Interestingly enough, I found the tests passed by using a simple TreeMap wrapped in Collections.synchronizedNavigableMap. If the performance costs are acceptable (and I think they likely are), I think it is worth considering making this change. Avoiding any Add-Opens at this early stage is much easier than getting rid of them later on.

            basil Basil Crow
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: