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

SecureGroovyScript.classpath does not support modifying jar while Jenkins is running

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Issue:

      Script approval is failing for groovy postbuild plugin, for classpath entries, when underlying jar file content is modified, when jar file is hosted on NFS mount.

      In think that the problem comes from the jar file which isn't correctly closed. On the linux FS we know that it's not a problem to delete a file which is used by a process but on NFS (or on Windows FS) you are doomed.

      File descriptors show:

      cat file-descriptors.txt | grep my.jar
      /nfs_mounted_path_to_classpath_entry/my.jar (deleted)
      /nfs_mounted_path_to_classpath_entry/my.jar (deleted)
      /nfs_mounted_path_to_classpath_entry/my.jar
      /nfs_mounted_path_to_classpath_entry/my.jar (deleted)
      

      Versions:

      Suggested fix (Jesse Glick can you review?):

      Make SecureGroovyScript.evaluate call URLClassLoader.close (Java 7)

      Error:

      2016-10-14 14:45:52.324-0400 [id=79]    WARNING o.j.p.s.scripts.ScriptApproval#configuring: nulljava.io.FileNotFoundException: /nfs_mounted_path_to_classpath_entry/my.jar (No such file or directory)
          at java.io.FileInputStream.open0(Native Method)
          at java.io.FileInputStream.open(Unknown Source)
          at java.io.FileInputStream.<init>(Unknown Source)
          at java.io.FileInputStream.<init>(Unknown Source)
          at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
          at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
          at java.net.URL.openStream(Unknown Source)
          at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.hashClasspathEntry(ScriptApproval.java:379)
          at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.configuring(ScriptApproval.java:491)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.configuring(SecureGroovyScript.java:109)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.readResolve(SecureGroovyScript.java:82)
          at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callReadResolve(SerializationMethodInvoker.java:66)
          at hudson.util.RobustReflectionConverter.unmarshal(RobustReflectionConverter.java:230)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
          at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
          at hudson.util.RobustReflectionConverter.unmarshalField(RobustReflectionConverter.java:352)
          at hudson.util.RobustReflectionConverter.doUnmarshal(RobustReflectionConverter.java:290)
          at hudson.util.RobustReflectionConverter.unmarshal(RobustReflectionConverter.java:229)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
          at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
          at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
          at hudson.util.CopyOnWriteList$ConverterImpl.unmarshal(CopyOnWriteList.java:197)
          at hudson.util.DescribableList$ConverterImpl.unmarshal(DescribableList.java:273)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
          at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
          at hudson.util.RobustReflectionConverter.unmarshalField(RobustReflectionConverter.java:352)
          at hudson.util.RobustReflectionConverter.doUnmarshal(RobustReflectionConverter.java:290)
          at hudson.util.RobustReflectionConverter.unmarshal(RobustReflectionConverter.java:229)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
          at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
          at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
          at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
          at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1189)
          at hudson.util.XStream2.unmarshal(XStream2.java:114)
          at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1173)
          at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1053)
          at hudson.XmlFile.read(XmlFile.java:142)
          at hudson.model.Items.load(Items.java:326)
          at hudson.model.ItemGroupMixIn.loadChildren(ItemGroupMixIn.java:116)
          at com.cloudbees.hudson.plugins.folder.AbstractFolder.onLoad(AbstractFolder.java:283)
          at com.cloudbees.hudson.plugins.folder.Folder.onLoad(Folder.java:104)
          at hudson.model.Items.load(Items.java:327)
          at hudson.model.ItemGroupMixIn.loadChildren(ItemGroupMixIn.java:116)
          at com.cloudbees.hudson.plugins.folder.AbstractFolder.onLoad(AbstractFolder.java:283)
          at com.cloudbees.hudson.plugins.folder.Folder.onLoad(Folder.java:104)
          at hudson.model.Items.load(Items.java:327)
          at jenkins.model.Jenkins$18.run(Jenkins.java:2719)
          at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
          at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
          at jenkins.model.Jenkins$8.runTask(Jenkins.java:925)
          at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
          at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at java.lang.Thread.run(Unknown Source)
      

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Where would that .close be called?

            Show
            abayer Andrew Bayer added a comment - Where would that .close be called?
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SecureGroovyScript.java
            http://jenkins-ci.org/commit/script-security-plugin/4e3565175ff3d313573d19e0aa98382866233fd3
            Log:
            [FIXED JENKINS-39159] If we create a URLClassLoader we should also close it.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SecureGroovyScript.java http://jenkins-ci.org/commit/script-security-plugin/4e3565175ff3d313573d19e0aa98382866233fd3 Log: [FIXED JENKINS-39159] If we create a URLClassLoader we should also close it.

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                owood Owen Wood
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: