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

NullPointerException when running groovy CLI without setting the offline cause

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: mail-watcher-plugin
    • Labels:
    • Environment:
      Version: 1.12
      Linux: centos
      Chrome:
      I've already tested twice:
      - Production environment based on the above configuration
      - Locally (mvn hpi:run)
    • Similar Issues:

      Description

      Stacktrace:

      java.lang.NullPointerException
      	at org.jenkinsci.plugins.mailwatcher.WatcherComputerListener.onTemporarilyOffline(WatcherComputerListener.java:110)
      	at hudson.model.Computer.setTemporarilyOffline(Computer.java:608)
      	at hudson.model.Computer.setTemporarilyOffline(Computer.java:585)
      	at hudson.model.Computer$setTemporarilyOffline.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      	at Script1$_run_closure1.doCall(Script1.groovy:3)
      	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:483)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
      	at groovy.lang.Closure.call(Closure.java:415)
      	at groovy.lang.Closure.call(Closure.java:428)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1379)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1351)
      	at org.codehaus.groovy.runtime.dgm$170.invoke(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:82)
      	at Script1.run(Script1.groovy:1)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
      	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
      	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:139)
      	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:111)
      	at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
      	at hudson.util.RemotingDiagnostics.executeGroovy(RemotingDiagnostics.java:108)
      	at jenkins.model.Jenkins._doScript(Jenkins.java:3556)
      	at jenkins.model.Jenkins.doScript(Jenkins.java:3533)
      	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:483)
      	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:298)
      	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:161)
      	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:96)
      	at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:121)
      	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
      	at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1074)
      	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:123)
      	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:114)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
      	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:48)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
      	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
      	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
      	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
      	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
      	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
      	at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
      	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
      	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
      	at org.mortbay.jetty.Server.handle(Server.java:285)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:628)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
      	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
      

      How to reproduce:

        Attachments

          Activity

          v2v Victor Martinez created issue -
          Hide
          v2v Victor Martinez added a comment -

          Added some extra validations and now it works!

              @Override
              public void onTemporarilyOffline(final Computer c, final OfflineCause cause) {
                  String causeString = "";
                  if (cause!=null) {
                      causeString = cause.toString();
                  }
                  getNotification().online(false)
                          .subject("marked temporarily offline")
                          .body(causeString)
                          .send(c)
                  ;
              }
          
          Show
          v2v Victor Martinez added a comment - Added some extra validations and now it works! @Override public void onTemporarilyOffline( final Computer c, final OfflineCause cause) { String causeString = ""; if (cause!= null ) { causeString = cause.toString(); } getNotification().online( false ) .subject( "marked temporarily offline" ) .body(causeString) .send(c) ; }
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Victor Martinez
          Path:
          src/main/java/org/jenkinsci/plugins/mailwatcher/WatcherComputerListener.java
          http://jenkins-ci.org/commit/mail-watcher-plugin/2505935ae40b2cb06f6568319c8532a1b2718c89
          Log:
          Avoid nullpointexception when cause is null since you can bypass validations as long as you use groovy api JENKINS-30220

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Victor Martinez Path: src/main/java/org/jenkinsci/plugins/mailwatcher/WatcherComputerListener.java http://jenkins-ci.org/commit/mail-watcher-plugin/2505935ae40b2cb06f6568319c8532a1b2718c89 Log: Avoid nullpointexception when cause is null since you can bypass validations as long as you use groovy api JENKINS-30220
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Victor Martinez
          Path:
          src/test/java/org/jenkinsci/plugins/mailwatcher/NodeStatusTest.java
          http://jenkins-ci.org/commit/mail-watcher-plugin/49b98e258d7ebe65d2073dbd88d67463ad451d78
          Log:
          [FIXED JENKINS-30220] Add UnitTest: validate whether a particular computer when is offline it fails if the cause is null

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Victor Martinez Path: src/test/java/org/jenkinsci/plugins/mailwatcher/NodeStatusTest.java http://jenkins-ci.org/commit/mail-watcher-plugin/49b98e258d7ebe65d2073dbd88d67463ad451d78 Log: [FIXED JENKINS-30220] Add UnitTest: validate whether a particular computer when is offline it fails if the cause is null
          scm_issue_link SCM/JIRA link daemon made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Victor Martinez
          Path:
          src/test/java/org/jenkinsci/plugins/mailwatcher/NodeStatusTest.java
          http://jenkins-ci.org/commit/mail-watcher-plugin/53ddf572cbafd2ff7e57bce2ced3b97008b0794b
          Log:
          Merge pull request #1 from v1v/nullcauseTestCase

          [FIXED JENKINS-30220] Add UnitTest: validate null Causes

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Victor Martinez Path: src/test/java/org/jenkinsci/plugins/mailwatcher/NodeStatusTest.java http://jenkins-ci.org/commit/mail-watcher-plugin/53ddf572cbafd2ff7e57bce2ced3b97008b0794b Log: Merge pull request #1 from v1v/nullcauseTestCase [FIXED JENKINS-30220] Add UnitTest: validate null Causes
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 165312 ] JNJira + In-Review [ 197680 ]

            People

            • Assignee:
              olivergondza Oliver Gond┼ża
              Reporter:
              v2v Victor Martinez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: