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

NullPointerException in h.p.e.p.content.ScriptContent.renderTemplate

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I have not managed to reproduce this bug consistently, it looks to me like a race condition somewhere.

      When the build finishes, instead of getting a proper email, we are receving an email containing the following stack trace:

      Exception raised during template rendering: Cannot invoke method getParent() on null object java.lang.NullPointerException: Cannot invoke method getParent() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at hudson.model.Queue$Executable$getParent.call(Unknown Source) at SimpleTemplateScript14$_run_closure4.doCall(SimpleTemplateScript14.groovy:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at groovy.lang.Closure.call(Closure.java:414) at groovy.lang.Closure.call(Closure.java:430) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2025) at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2066) at org.codehaus.groovy.runtime.dgm$163.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at SimpleTemplateScript14.run(SimpleTemplateScript14.groovy:33) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:168) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:180) at hudson.plugins.emailext.plugins.content.ScriptContent.renderTemplate(ScriptContent.java:151) at hudson.plugins.emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:81) at hudson.plugins.emailext.plugins.content.AbstractEvalContent.evaluate(AbstractEvalContent.java:76) at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:202) at org.jenkinsci.plugins.tokenmacro.Parser.processToken(Parser.java:323) at org.jenkinsci.plugins.tokenmacro.Action$KiHW1UeqOdqAwZul.run(Unknown Source) at org.parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.SequenceMatcher.match(SequenceMatcher.java:46) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.FirstOfMatcher.match(FirstOfMatcher.java:41) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.ZeroOrMoreMatcher.match(ZeroOrMoreMatcher.java:39) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.matchers.SequenceMatcher.match(SequenceMatcher.java:46) at org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) at org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351) at org.parboiled.parserunners.BasicParseRunner.run(BasicParseRunner.java:72) at org.parboiled.parserunners.ReportingParseRunner.runBasicMatch(ReportingParseRunner.java:86) at org.parboiled.parserunners.ReportingParseRunner.run(ReportingParseRunner.java:66) at org.parboiled.parserunners.AbstractParseRunner.run(AbstractParseRunner.java:81) at org.parboiled.parserunners.AbstractParseRunner.run(AbstractParseRunner.java:76) at org.jenkinsci.plugins.tokenmacro.Parser.process(Parser.java:85) at org.jenkinsci.plugins.tokenmacro.Parser.process(Parser.java:74) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:199) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:237) at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:80) at hudson.plugins.emailext.ExtendedEmailPublisher.addContent(ExtendedEmailPublisher.java:880) at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:753) at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:451) at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441) at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690) at hudson.model.Build$BuildExecution.cleanUp(Build.java:196) at hudson.model.Run.execute(Run.java:1862) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429)
      

      We use:
      Jenkins ver. 2.190.1
      Email extension plugin : 2.68

        Attachments

          Activity

          Hide
          slide_o_mix Alex Earl added a comment -

          No, I don't think it's the problem. Adding a null check would be a good idea.

          Show
          slide_o_mix Alex Earl added a comment - No, I don't think it's the problem. Adding a null check would be a good idea.
          Hide
          slide_o_mix Alex Earl added a comment -

          Did you ever get this resolved?

          Show
          slide_o_mix Alex Earl added a comment - Did you ever get this resolved?
          Hide
          andrea_giardini Andrea Giardini added a comment -

          Hi Alex

          I believe changing the template did the trick. We replaced the code above with:

          Map changeSetsByBuild = upstreamBuilds.grep().collectEntries {
            [(it.getParent().name): ['changesets': it.changeSets, 'buildurl': rooturl + it.getUrl()]]
          }

          Since then we didn't have another NPE triggered. But this was always difficult to reproduce so I can't be 100% sure.

          Does this make sense to you?

          Show
          andrea_giardini Andrea Giardini added a comment - Hi Alex I believe changing the template did the trick. We replaced the code above with: Map changeSetsByBuild = upstreamBuilds.grep().collectEntries { [(it.getParent().name): [ 'changesets' : it.changeSets, 'buildurl' : rooturl + it.getUrl()]] } Since then we didn't have another NPE triggered. But this was always difficult to reproduce so I can't be 100% sure. Does this make sense to you?
          Hide
          slide_o_mix Alex Earl added a comment -

          The addition of the grep will basically filter out any null items. So, it does make sense. I'm not sure why there would be null items in the upstreamBuilds collection though. Do you feel ok closing this out?

          Show
          slide_o_mix Alex Earl added a comment - The addition of the grep will basically filter out any null items. So, it does make sense. I'm not sure why there would be null items in the upstreamBuilds collection though. Do you feel ok closing this out?
          Hide
          andrea_giardini Andrea Giardini added a comment -

          Makes sense, please close the issue and thank you for the feedback!

          Show
          andrea_giardini Andrea Giardini added a comment - Makes sense, please close the issue and thank you for the feedback!

            People

            Assignee:
            slide_o_mix Alex Earl
            Reporter:
            andrea_giardini Andrea Giardini
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: