java.lang.NullPointerException

Jenkins JIRA | Jos Backus | 10 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Stacktrace: {code} java.lang.NullPointerException at hudson.plugins.s3.S3BucketPublisher.perform(S3BucketPublisher.java:124) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:68) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:49) at hudson.security.ACL.impersonate(ACL.java:213) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:47) 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:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) {code} Pipeline code snippet that triggers the NPE: {code} step([$class: 'S3BucketPublisher', entries: [[bucket: bucket, flatten: true, noUploadOnFailure: true, selectedRegion: region, sourceFile: target, storageClass: 'STANDARD', uploadFromSlave: true, useServerSideEncryption: false]], profileName: profile, userMetadata: []]) {code} Issue looks to be that {{run.getResult()}} can return {{null}}. Workaround: {code} --- a/src/main/java/hudson/plugins/s3/S3BucketPublisher.java +++ b/src/main/java/hudson/plugins/s3/S3BucketPublisher.java @@ -121,7 +121,10 @@ public final class S3BucketPublisher extends Recorder implements SimpleBuildStep public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException { - final boolean buildFailed = run.getResult().equals(Result.FAILURE); + final boolean buildFailed = Result.FAILURE.equals(run.getResult()); + if (buildFailed) { + log(listener.getLogger(), "Run failed."); + } final S3Profile profile = getProfile(); if (profile == null) { {code}

    Jenkins JIRA | 10 months ago | Jos Backus
    java.lang.NullPointerException
  2. 0

    Stacktrace: {code} java.lang.NullPointerException at hudson.plugins.s3.S3BucketPublisher.perform(S3BucketPublisher.java:124) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:68) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:49) at hudson.security.ACL.impersonate(ACL.java:213) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:47) 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:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) {code} Pipeline code snippet that triggers the NPE: {code} step([$class: 'S3BucketPublisher', entries: [[bucket: bucket, flatten: true, noUploadOnFailure: true, selectedRegion: region, sourceFile: target, storageClass: 'STANDARD', uploadFromSlave: true, useServerSideEncryption: false]], profileName: profile, userMetadata: []]) {code} Issue looks to be that {{run.getResult()}} can return {{null}}. Workaround: {code} --- a/src/main/java/hudson/plugins/s3/S3BucketPublisher.java +++ b/src/main/java/hudson/plugins/s3/S3BucketPublisher.java @@ -121,7 +121,10 @@ public final class S3BucketPublisher extends Recorder implements SimpleBuildStep public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException { - final boolean buildFailed = run.getResult().equals(Result.FAILURE); + final boolean buildFailed = Result.FAILURE.equals(run.getResult()); + if (buildFailed) { + log(listener.getLogger(), "Run failed."); + } final S3Profile profile = getProfile(); if (profile == null) { {code}

    Jenkins JIRA | 10 months ago | Jos Backus
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at hudson.plugins.s3.S3BucketPublisher.perform()
    2. hudson.plugins.s3
      S3BucketPublisher.perform
      1. hudson.plugins.s3.S3BucketPublisher.perform(S3BucketPublisher.java:124)
      1 frame
    3. org.jenkinsci.plugins
      AbstractSynchronousNonBlockingStepExecution$1$1.call
      1. org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:68)
      2. org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59)
      3. org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:49)
      3 frames
    4. Hudson
      ACL.impersonate
      1. hudson.security.ACL.impersonate(ACL.java:213)
      1 frame
    5. org.jenkinsci.plugins
      AbstractSynchronousNonBlockingStepExecution$1.run
      1. org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:47)
      1 frame
    6. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      2. java.util.concurrent.FutureTask.run(FutureTask.java:266)
      3. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      4. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      5. java.lang.Thread.run(Thread.java:745)
      5 frames