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

NPE after updating EnvInject Plugin from 1.90 to 1.91.1

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: envinject-plugin
    • Labels:
      None
    • Environment:
      Jenkins LTS 1.596.2
    • Similar Issues:

      Description

      java.lang.NullPointerException
      at org.jenkinsci.lib.envinject.EnvInjectAction$1.transformEntry(EnvInjectAction.java:94)
      at org.jenkinsci.lib.envinject.EnvInjectAction$1.transformEntry(EnvInjectAction.java:92)
      at com.google.common.collect.Maps$TransformedEntriesMap$1$1.apply(Maps.java:1218)
      at com.google.common.collect.Maps$TransformedEntriesMap$1$1.apply(Maps.java:1216)
      at com.google.common.collect.Iterators$8.next(Iterators.java:812)
      at java.util.AbstractMap.putAll(AbstractMap.java:272)
      at java.util.TreeMap.putAll(TreeMap.java:321)
      at org.jenkinsci.lib.envinject.service.EnvInjectSavable.saveEnvironment(EnvInjectSavable.java:54)
      at org.jenkinsci.lib.envinject.EnvInjectAction.writeReplace(EnvInjectAction.java:91)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:89)
      at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:99)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
      at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
      at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
      at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:223)
      at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:210)
      at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:182)
      at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
      at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:167)
      at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:108)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
      at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
      at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
      at hudson.XmlFile.write(XmlFile.java:178)
      at hudson.model.Run.save(Run.java:1929)
      at hudson.plugins.changelog_history.ChangeLogHistoryRunListener.copyChangeLogs(ChangeLogHistoryRunListener.java:82)
      at hudson.plugins.changelog_history.ChangeLogHistoryRunListener.onDeleted(ChangeLogHistoryRunListener.java:50)
      at hudson.plugins.changelog_history.ChangeLogHistoryRunListener.onDeleted(ChangeLogHistoryRunListener.java:40)
      at hudson.model.listeners.RunListener.fireDeleted(RunListener.java:244)
      at hudson.model.Run.delete(Run.java:1502)
      at hudson.tasks.LogRotator.perform(LogRotator.java:129)
      at hudson.model.Job.logRotate(Job.java:449)
      at hudson.model.Run.execute(Run.java:1823)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:89)
      at hudson.model.Executor.run(Executor.java:240)

        Attachments

          Issue Links

            Activity

            Hide
            signiant_devops Signiant Devops added a comment -

            We've just ran into this as well and it's "really bad". We've hit it using the Promoted builds plugin (which I'm guessing uses EnvInject to set the vars). What happens is that all environment variables for a build are lost after a Jenkins restart AFTER we have promoted that build. The test case is:

            Run a build
            promote said build (any promotion process)
            check in the logs - see we got the NPE
            Check in the jobs folder for the build (ie. in our case /var/lib/jenkins/myproject/builds/574
            Note that the "injectedEnvVars.txt" file is 0 bytes

            What we see is that subsequent promotions of the same build are fine...until Jenkins is restarted. After which, presumably, it reads the file and zaps all the variables.

            Show
            signiant_devops Signiant Devops added a comment - We've just ran into this as well and it's "really bad". We've hit it using the Promoted builds plugin (which I'm guessing uses EnvInject to set the vars). What happens is that all environment variables for a build are lost after a Jenkins restart AFTER we have promoted that build. The test case is: Run a build promote said build (any promotion process) check in the logs - see we got the NPE Check in the jobs folder for the build (ie. in our case /var/lib/jenkins/myproject/builds/574 Note that the "injectedEnvVars.txt" file is 0 bytes What we see is that subsequent promotions of the same build are fine...until Jenkins is restarted. After which, presumably, it reads the file and zaps all the variables.
            Hide
            pratapsingh Pratap Singh added a comment -

            We are also facing the same issue and its recursive. Any update on this as it does not look good on production .

            Show
            pratapsingh Pratap Singh added a comment - We are also facing the same issue and its recursive. Any update on this as it does not look good on production .
            Hide
            tcb_xy Tim-Christian Bloss added a comment -

            Same here.

            Debian GNU/Linux 8 / AMD64
            LANG=de_DE.UTF-8

            Apache Tomcat/7.0.54
            Oracle JDK 1.8.0_45 / AMD64
            -Duser.language=de -Duser.country=DE -Dfile.encoding=UTF-8

            Jenkins LTS 1.596.3

            EnvInject Plugin 1.91.3

            Show
            tcb_xy Tim-Christian Bloss added a comment - Same here. Debian GNU/Linux 8 / AMD64 LANG=de_DE.UTF-8 Apache Tomcat/7.0.54 Oracle JDK 1.8.0_45 / AMD64 -Duser.language=de -Duser.country=DE -Dfile.encoding=UTF-8 Jenkins LTS 1.596.3 EnvInject Plugin 1.91.3
            Hide
            aheritier Arnaud Héritier added a comment -

            Reproduced with Signiant Devops usecase with Environment Injector Plugin 1.91.3 and promoted builds plugin 2.21

            INFO: test/promotion/Promotion #5 main build action completed: SUCCESS
            java.lang.NullPointerException
            	at org.jenkinsci.lib.envinject.EnvInjectAction$1.transformEntry(EnvInjectAction.java:94)
            	at org.jenkinsci.lib.envinject.EnvInjectAction$1.transformEntry(EnvInjectAction.java:92)
            	at com.google.common.collect.Maps$TransformedEntriesMap$1$1.apply(Maps.java:1218)
            	at com.google.common.collect.Maps$TransformedEntriesMap$1$1.apply(Maps.java:1216)
            	at com.google.common.collect.Iterators$8.next(Iterators.java:812)
            	at java.util.AbstractMap.putAll(AbstractMap.java:272)
            	at java.util.TreeMap.putAll(TreeMap.java:322)
            	at org.jenkinsci.lib.envinject.service.EnvInjectSavable.saveEnvironment(EnvInjectSavable.java:54)
            	at org.jenkinsci.lib.envinject.EnvInjectAction.writeReplace(EnvInjectAction.java:91)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            	at java.lang.reflect.Method.invoke(Method.java:606)
            	at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:89)
            	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:99)
            	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
            	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
            	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
            	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
            	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
            	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
            	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
            	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
            	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
            	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:223)
            	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:210)
            	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:182)
            	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
            	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:167)
            	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:108)
            	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
            	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
            	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
            	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
            	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
            	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
            	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
            	at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
            	at hudson.XmlFile.write(XmlFile.java:178)
            	at hudson.model.Run.save(Run.java:1901)
            	at hudson.plugins.promoted_builds.Promotion$RunnerImpl.post2(Promotion.java:246)
            	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:670)
            	at hudson.model.Run.execute(Run.java:1766)
            	at hudson.model.Run.run(Run.java:1679)
            	at hudson.plugins.promoted_builds.Promotion.run(Promotion.java:174)
            	at hudson.model.ResourceController.execute(ResourceController.java:98)
            	at hudson.model.Executor.run(Executor.java:374)
            

            We have this error if we do the promotion after having restarted Jenkins. After the error `injectedEnvVars.txt`is empty

            Show
            aheritier Arnaud Héritier added a comment - Reproduced with Signiant Devops usecase with Environment Injector Plugin 1.91.3 and promoted builds plugin 2.21 INFO: test/promotion/Promotion #5 main build action completed: SUCCESS java.lang.NullPointerException at org.jenkinsci.lib.envinject.EnvInjectAction$1.transformEntry(EnvInjectAction.java:94) at org.jenkinsci.lib.envinject.EnvInjectAction$1.transformEntry(EnvInjectAction.java:92) at com.google.common.collect.Maps$TransformedEntriesMap$1$1.apply(Maps.java:1218) at com.google.common.collect.Maps$TransformedEntriesMap$1$1.apply(Maps.java:1216) at com.google.common.collect.Iterators$8.next(Iterators.java:812) at java.util.AbstractMap.putAll(AbstractMap.java:272) at java.util.TreeMap.putAll(TreeMap.java:322) at org.jenkinsci.lib.envinject.service.EnvInjectSavable.saveEnvironment(EnvInjectSavable.java:54) at org.jenkinsci.lib.envinject.EnvInjectAction.writeReplace(EnvInjectAction.java:91) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:89) at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:99) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64) at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:223) at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:210) at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:182) at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138) at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:167) at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:108) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82) at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37) at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026) at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015) at com.thoughtworks.xstream.XStream.toXML(XStream.java:988) at hudson.XmlFile.write(XmlFile.java:178) at hudson.model.Run.save(Run.java:1901) at hudson.plugins.promoted_builds.Promotion$RunnerImpl.post2(Promotion.java:246) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:670) at hudson.model.Run.execute(Run.java:1766) at hudson.model.Run.run(Run.java:1679) at hudson.plugins.promoted_builds.Promotion.run(Promotion.java:174) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:374) We have this error if we do the promotion after having restarted Jenkins. After the error `injectedEnvVars.txt`is empty
            Hide
            aheritier Arnaud Héritier added a comment -

            The change between 1.90 and 1.91 which could be related to this bug is the upgrade of the envinject-lib from 1.19 to 1.21 to fix JENKINS-23447

            Show
            aheritier Arnaud Héritier added a comment - The change between 1.90 and 1.91 which could be related to this bug is the upgrade of the envinject-lib from 1.19 to 1.21 to fix JENKINS-23447
            Hide
            aheritier Arnaud Héritier added a comment -

            After few investigations this NPE comes from this commit : https://github.com/jenkinsci/envinject-lib/commit/e181ac473a9ea3d8b531ff0f061e7ca7071f7d87
            I'll send the PR tomorrow. The fix is "easy" the bug comes from the fact that when jenkins is reloaded 'sensibleVariables' (transient) is null.
            cc Nicolas De Loof

            Show
            aheritier Arnaud Héritier added a comment - After few investigations this NPE comes from this commit : https://github.com/jenkinsci/envinject-lib/commit/e181ac473a9ea3d8b531ff0f061e7ca7071f7d87 I'll send the PR tomorrow. The fix is "easy" the bug comes from the fact that when jenkins is reloaded 'sensibleVariables' (transient) is null. cc Nicolas De Loof
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Arnaud Héritier
            Path:
            src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
            http://jenkins-ci.org/commit/envinject-lib/b2ffaa07446a586997545fb777500efaf89c9437
            Log:
            JENKINS-27665: Avoid NPE when sensibleVariables isn't set
            usecase: EnvInjectAction.writeReplace() is called after a promotion (promoted build plugin) launched from a build recorded before jenkins was restarted. EnvInjectAction.overrideAll() isn't called thus sensibleVariables is null.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Arnaud Héritier Path: src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java http://jenkins-ci.org/commit/envinject-lib/b2ffaa07446a586997545fb777500efaf89c9437 Log: JENKINS-27665 : Avoid NPE when sensibleVariables isn't set usecase: EnvInjectAction.writeReplace() is called after a promotion (promoted build plugin) launched from a build recorded before jenkins was restarted. EnvInjectAction.overrideAll() isn't called thus sensibleVariables is null.
            Hide
            aheritier Arnaud Héritier added a comment -

            a PR by Oleg Nenashev already exists to solve this problem: https://github.com/jenkinsci/envinject-lib/pull/4

            Show
            aheritier Arnaud Héritier added a comment - a PR by Oleg Nenashev already exists to solve this problem: https://github.com/jenkinsci/envinject-lib/pull/4
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Oleg Nenashev
            Path:
            src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
            http://jenkins-ci.org/commit/envinject-lib/8e3c2bbf549b59318a7432c368870684000fbf4e
            Log:
            Merge pull request #4 from oleg-nenashev/JENKINS-27363

            [JENKINS-27363,JENKINS-27665] - Annotate sensibleVariables (may be null)

            Compare: https://github.com/jenkinsci/envinject-lib/compare/0033cdf67151...8e3c2bbf549b

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java http://jenkins-ci.org/commit/envinject-lib/8e3c2bbf549b59318a7432c368870684000fbf4e Log: Merge pull request #4 from oleg-nenashev/ JENKINS-27363 [JENKINS-27363,JENKINS-27665] - Annotate sensibleVariables (may be null) Compare: https://github.com/jenkinsci/envinject-lib/compare/0033cdf67151...8e3c2bbf549b
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            The issue should be fixed in 1.91.4. Sorry for the long delay, we did not get a response from plugin owners and had to wait for several weeks.

            Show
            oleg_nenashev Oleg Nenashev added a comment - The issue should be fixed in 1.91.4. Sorry for the long delay, we did not get a response from plugin owners and had to wait for several weeks.

              People

              • Assignee:
                oleg_nenashev Oleg Nenashev
                Reporter:
                slawomir_czarko Slawomir Czarko
              • Votes:
                7 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: