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

NullPointerException from gerrit plugin due to lack of configuration

    XMLWordPrintable

Details

    • gerrit-code-review-0.2

    Description

      It seems that the most basic use case of gerrit plugin documented at https://wiki.jenkins.io/display/JENKINS/Gerrit+Code+Review+Plugin does not mention how the user is supposed to configure access to Gerrit server, or even to mention which Gerrit server should be used.

       

       

      java.lang.NullPointerException
      at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:874)
      at com.cloudbees.plugins.credentials.CredentialsProvider.findCredentialById(CredentialsProvider.java:852)
      at org.jenkinsci.plugins.credentialsbinding.MultiBinding.getCredentials(MultiBinding.java:151)
      at org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding.bind(UsernamePasswordMultiBinding.java:76)
      at org.jenkinsci.plugins.credentialsbinding.impl.BindingStep$Execution.start(BindingStep.java:114)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:229)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153)
      at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
      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.AbstractCallSite.call(AbstractCallSite.java:113)
      at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:19)
      at jenkins.plugins.gerrit.workflow.Gerrit.post(jar:file:/var/lib/jenkins/plugins/gerrit/WEB-INF/lib/gerrit.jar!/jenkins/plugins/gerrit/workflow/Gerrit.groovy:62)
      at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2030)
      at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2015)
      at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2056)
      at jenkins.plugins.gerrit.workflow.Gerrit.post(jar:file:/var/lib/jenkins/plugins/gerrit/WEB-INF/lib/gerrit.jar!/jenkins/plugins/gerrit/workflow/Gerrit.groovy:59)
      at jenkins.plugins.gerrit.workflow.Gerrit.review(jar:file:/var/lib/jenkins/plugins/gerrit/WEB-INF/lib/gerrit.jar!/jenkins/plugins/gerrit/workflow/Gerrit.groovy:40)
      at jenkins.plugins.gerrit.workflow.Gerrit.node(jar:file:/var/lib/jenkins/plugins/gerrit/WEB-INF/lib/gerrit.jar!/jenkins/plugins/gerrit/workflow/Gerrit.groovy:50)
      at jenkins.plugins.gerrit.workflow.Gerrit.review(jar:file:/var/lib/jenkins/plugins/gerrit/WEB-INF/lib/gerrit.jar!/jenkins/plugins/gerrit/workflow/Gerrit.groovy:32)
      at WorkflowScript.run(WorkflowScript:15)
      at ___cps.transform___(Native Method)
      at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      at sun.reflect.GeneratedMethodAccessor304.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
      at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
      at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
      at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
      at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:331)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:82)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243)
      at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231)
      at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      

       

      Attachments

        Activity

          oleg_nenashev Oleg Nenashev added a comment -

          Sounds to be a credentials issue actually

          oleg_nenashev Oleg Nenashev added a comment - Sounds to be a credentials issue actually
          ssbarnea Sorin Sbarnea added a comment -

          This happens when you configure gerrit without authetication, which is ok for reading.... until you attempt to add a comment. The normal behaviour would be to have a clear message that sounds like "Failed to perform xxx as this requires authentication" instead NullPointerException stacktrace. 

          ssbarnea Sorin Sbarnea added a comment - This happens when you configure gerrit without authetication, which is ok for reading.... until you attempt to add a comment. The normal behaviour would be to have a clear message that sounds like "Failed to perform xxx as this requires authentication" instead NullPointerException stacktrace. 

          oleg_nenashev did you even look at the line in the credentials plugin: https://github.com/jenkinsci/credentials-plugin/blob/845bb7946a53650da1eeb457152d4296eaeb58c5/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java#L874

          public static <C extends IdCredentials> C findCredentialById(@NonNull String id, @NonNull Class<C> type,
          @NonNull Run<?, ?> run,
          @Nullable List<DomainRequirement> domainRequirements) {
          id.getClass(); // throw NPE if null;
          

          It's the id.getClass(); // throw NPE if null line that is verifing the @NonNull contract on the id parameter.

          Nothing to do with the credentials plugin. If somebody passes null to a @NonNull parameter, the person doing the passing is the root cause... not the credentials plugin.

          stephenconnolly Stephen Connolly added a comment - oleg_nenashev did you even look at the line in the credentials plugin: https://github.com/jenkinsci/credentials-plugin/blob/845bb7946a53650da1eeb457152d4296eaeb58c5/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java#L874 public static <C extends IdCredentials> C findCredentialById(@NonNull String id, @NonNull Class <C> type, @NonNull Run<?, ?> run, @Nullable List<DomainRequirement> domainRequirements) { id.getClass(); // throw NPE if null ; It's the id.getClass(); // throw NPE if null line that is verifing the @NonNull contract on the id parameter. Nothing to do with the credentials plugin. If somebody passes null to a @NonNull parameter, the person doing the passing is the root cause... not the credentials plugin.

          stephenconnolly agreed, let me fix this in the Gerrit plugin and just display a warning that feedback cannot be sent to Gerrit because of missing credentials.

          lucamilanesio Luca Domenico Milanesio added a comment - stephenconnolly agreed, let me fix this in the Gerrit plugin and just display a warning that feedback cannot be sent to Gerrit because of missing credentials.
          lucamilanesio Luca Domenico Milanesio added a comment - PR with the fix available at: https://github.com/jenkinsci/gerrit-code-review-plugin/pull/14

          People

            lucamilanesio Luca Domenico Milanesio
            ssbarnea Sorin Sbarnea
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: