get lock by resource name result in NPE
clockrun opened this issue · 3 comments
Jenkins and plugins versions report
Environment
Jenkins: 2.426.1
OS: Linux - 5.15.125-gardenlinux-cloud-amd64
Java: 17.0.9 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
Office-365-Connector:4.20.2
Parameterized-Remote-Trigger:3.2.0
ace-editor:1.1
active-directory:2.34
allure-jenkins-plugin:2.31.1
analysis-model-api:11.13.0
ansicolor:1.0.4
ant:497.v94e7d9fffa_b_9
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
apache-httpcomponents-client-5-api:5.2.3-1.0
archived-artifact-url-viewer:1.1
authentication-tokens:1.53.v1c90fd9191a_b_
aws-credentials:218.v1b_e9466ec5da_
aws-java-sdk:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-cloudformation:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-codebuild:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-ec2:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-ecr:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-ecs:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-efs:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-elasticbeanstalk:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-iam:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-kinesis:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-logs:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-minimal:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-secretsmanager:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-sns:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-sqs:1.12.610-428.v849169a_01b_a_5
aws-java-sdk-ssm:1.12.610-428.v849169a_01b_a_5
azure-commons:1.1.3
badge:1.9.1
basic-branch-build-strategies:81.v05e333931c7d
blackduck-detect:9.0.0
blueocean:1.27.9
blueocean-autofavorite:1.2.5
blueocean-bitbucket-pipeline:1.27.9
blueocean-commons:1.27.9
blueocean-config:1.27.9
blueocean-core-js:1.27.9
blueocean-dashboard:1.27.9
blueocean-display-url:2.4.2
blueocean-events:1.27.9
blueocean-git-pipeline:1.27.9
blueocean-github-pipeline:1.27.9
blueocean-i18n:1.27.9
blueocean-jwt:1.27.9
blueocean-personalization:1.27.9
blueocean-pipeline-api-impl:1.27.9
blueocean-pipeline-editor:1.27.9
blueocean-pipeline-scm-api:1.27.9
blueocean-rest:1.27.9
blueocean-rest-impl:1.27.9
blueocean-web:1.27.9
bootstrap4-api:4.6.0-6
bootstrap5-api:5.3.2-3
bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9
branch-api:2.1135.v8de8e7899051
build-failure-analyzer:2.5.0
build-history-manager:1.7.1
build-user-vars-plugin:1.9
caffeine-api:3.1.8-133.v17b_1ff2e0599
checkmarx:2023.2.6
checks-api:2.0.2
cloud-stats:320.v96b_65297a_4b_b_
cloudbees-bitbucket-branch-source:856.v04c46c86f911
cloudbees-folder:6.858.v898218f3609d
cobertura:1.17
code-coverage-api:4.99.0
command-launcher:107.v773860566e2e
commons-httpclient3-api:3.1-3
commons-lang3-api:3.13.0-62.v7d18e55f51e2
commons-text-api:1.11.0-95.v22a_d30ee5d36
concurrent-step:1.0.0
config-file-provider:959.vcff671a_4518b_
configuration-as-code:1763.vb_fe9c1b_83f7b
copyartifact:722.v0662a_9b_e22a_c
coverage:1.6.0
credentials:1311.vcf0a_900b_37c2
credentials-binding:642.v737c34dea_6c2
cucumber-reports:5.8.0
dashboard-view:2.495.v07e81500c3f2
data-tables-api:1.13.8-2
database:191.vd5981b_97a_5fa_
database-postgresql:100.v2418e0a_c6909
dependency-check-jenkins-plugin:5.4.3
dependency-track:4.3.1
disk-usage:1.2
display-url-api:2.200.vb_9327d658781
docker-commons:439.va_3cb_0a_6a_fb_29
docker-java-api:3.3.4-86.v39b_a_5ede342c
docker-plugin:1.5
docker-workflow:572.v950f58993843
durable-task:523.va_a_22cf15d5e0
echarts-api:5.4.3-2
email-ext:2.102
emailext-template:1.5
embeddable-build-status:459.v428d6761597b_
extended-choice-parameter:376.v2e02857547b_a_
extended-read-permission:53.v6499940139e5
extensible-choice-parameter:1.8.1
external-monitor-job:215.v2e88e894db_f8
favorite:2.208.v91d65b_7792a_c
font-awesome-api:6.5.1-1
forensics-api:2.3.0
generic-webhook-trigger:1.88.2
git:5.2.1
git-client:4.6.0
git-server:99.va_0826a_b_cdfa_d
github:1.37.3.1
github-api:1.318-461.v7a_c09c9fa_d63
github-branch-source:1767.va_7d01ea_c7256
github-oauth:597.ve0c3480fcb_d0
google-oauth-plugin:1.330.vf5e86021cb_ec
gradle:2.9
groovy-postbuild:228.vcdb_cf7265066
gson-api:2.10.1-3.vb_25b_599b_e4f8
h2-api:11.1.4.199-12.v9f4244395f7a_
handlebars:3.0.8
handy-uri-templates-2-api:2.1.8-30.v7e777411b_148
htmlpublisher:1.32
http_request:1.18
influxdb:3.6
instance-identity:185.v303dc7c645f9
ionicons-api:56.v1b_1c8c49374e
jackson2-api:2.15.3-372.v309620682326
jacoco:3.3.5
jakarta-activation-api:2.0.1-3
jakarta-mail-api:2.0.1-3
javadoc:243.vb_b_503b_b_45537
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-9
jaxb:2.3.9-1
jdk-tool:73.vddf737284550
jenkins-design-language:1.27.9
jersey2-api:2.41-133.va_03323b_a_1396
jfrog:1.5.0
jira:3.12
jjwt-api:0.11.5-77.v646c772fddb_0
jnr-posix-api:3.1.18-1
job-dsl:1.87
job-import-plugin:3.6
joda-time-api:2.12.5-5.v5495a_235fedf
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.7.1-1
jsch:0.2.8-65.v052c39de79b_2
json-api:20231013-3.v20f3c247f2fe
json-path-api:2.8.0-5.v07cb_a_1ca_738c
junit:1252.vfc2e5efa_294f
kubernetes:4151.v6fa_f0fb_0b_4c9
kubernetes-cd:2.3.1
kubernetes-cli:1.12.1
kubernetes-client-api:6.8.1-224.vd388fca_4db_3b_
kubernetes-credentials:0.11
ldap:711.vb_d1a_491714dc
lockable-resources:1218.va_3dd45e2b_fa_7
mailer:463.vedf8358e006b_
mask-passwords:173.v6a_077a_291eb_5
matrix-auth:3.2.1
matrix-project:822.v01b_8c85d16d2
maven-plugin:3.23
mercurial:1260.vdfb_723cdcc81
metrics:4.2.18-442.v02e107157925
mina-sshd-api-common:2.11.0-86.v836f585d47fa_
mina-sshd-api-core:2.11.0-86.v836f585d47fa_
momentjs:1.1.1
nodejs:1.6.1
oauth-credentials:0.646.v02b_66dc03d2e
okhttp-api:4.11.0-157.v6852a_a_fa_ec11
openshift-client:1.1.0.420.v8817277c1990
openshift-sync:1.1.0.795.v95fa_27a_a_e287
pam-auth:1.10
parameterized-scheduler:255.v73827fcdf618
performance:951.v5600a_c6422ed
permissive-script-security:0.7
pipeline-aws:1.43
pipeline-build-step:540.vb_e8849e1a_b_d8
pipeline-github:2.8-155.8eab375ac9f8
pipeline-githubnotify-step:49.vf37bf92d2bc8
pipeline-graph-analysis:202.va_d268e64deb_3
pipeline-groovy-lib:689.veec561a_dee13
pipeline-input-step:477.v339683a_8d55e
pipeline-maven:1362.vee39a_d4b_02b_1
pipeline-maven-api:1362.vee39a_d4b_02b_1
pipeline-milestone-step:111.v449306f708b_7
pipeline-model-api:2.2151.ve32c9d209a_3f
pipeline-model-definition:2.2151.ve32c9d209a_3f
pipeline-model-extensions:2.2151.ve32c9d209a_3f
pipeline-npm:155.ve2e393062d86
pipeline-rest-api:2.34
pipeline-stage-step:305.ve96d0205c1c6
pipeline-stage-tags-metadata:2.2151.ve32c9d209a_3f
pipeline-stage-view:2.34
pipeline-utility-steps:2.16.0
plain-credentials:143.v1b_df8b_d3b_e48
plugin-util-api:3.6.0
popper-api:1.16.1-3
popper2-api:2.11.6-4
postgresql-api:42.6.0-31.vb_7e76dc13969
prism-api:1.29.0-10
pubsub-light:1.18
pyenv-pipeline:2.1.2
rebuild:330.v645b_7df10e2a_
resource-disposer:0.23
robot:3.4.0
saferestart:0.7
saml:4.429.v9a_781a_61f1da_
sapsystemhealthcheck:1.23-SNAPSHOT (private-8489f1a4-I335255)
scm-api:683.vb_16722fb_b_80b_
script-security:1294.v99333c047434
seleniumhtmlreport:1.1
shiningpanda:0.24
sidebar-link:2.4.1
slack:684.v833089650554
snakeyaml-api:2.2-111.vc6598e30cc65
soapui-pro-functional-testing:1.10
sonar:2.16.1
sse-gateway:1.26
ssh-agent:346.vda_a_c4f2c8e50
ssh-credentials:308.ve4497b_ccd8f4
ssh-slaves:2.947.v64ee6b_f87b_c1
sshd:3.312.v1c601b_c83b_0e
structs:325.vcb_307d2a_2782
timestamper:1.26
token-macro:400.v35420b_922dcb_
trilead-api:2.133.vfb_8a_7b_9c5dd1
uno-choice:2.8.1
variant:60.v7290fc0eb_b_cd
warnings-ng:10.5.2
webhook-step:327.vb_58f208a_7783
windows-slaves:1.8.1
workflow-aggregator:596.v8c21c963d92d
workflow-api:1283.v99c10937efcb_
workflow-basic-steps:1042.ve7b_140c4a_e0c
workflow-cps:3826.v3b_5707fe44da_
workflow-cps-global-lib:609.vd95673f149b_b
workflow-durable-task-step:1313.vcb_970b_d2a_fb_3
workflow-job:1385.vb_58b_86ea_fff1
workflow-multibranch:756.v891d88f2cd46
workflow-scm-step:415.v434365564324
workflow-step-api:639.v6eca_cd8c04a_a_
workflow-support:865.v43e78cc44e0d
ws-cleanup:0.45
What Operating System are you using (both controller, and any agents involved in the problem)?
running Jenkins on kubernetes
Reproduction steps
execute below code
node{
stage("test"){
try {
lock(resource: "testing", quantity: 1, resourceSelectStrategy: 'sequential'){
echo "get lock"
}
} catch (ex) {
echo "I am in catch block"
println ex
frame_list = ex.getStackTrace()
def sb = new StringBuilder(ex.getMessage() + " : stacktrace")
for(frame in frame_list) {
sb.append("\t" + frame.toString() + "\n")
}
println(sb.toString())
}
}
}
Expected Results
02:54:40 [Pipeline] {
02:54:40 [Pipeline] stage
02:54:40 [Pipeline] { (test)
02:54:40 [Pipeline] lock
02:54:40 Trying to acquire lock on [Label: testing, Quantity: 1]
02:54:40 Lock acquired on [Label: testing, Quantity: 1]
02:54:40 [Pipeline] {
02:54:40 [Pipeline] echo
02:54:40 get lock
02:54:40 [Pipeline] }
02:54:40 Lock released on resource [Label: testing, Quantity: 1]
02:54:40 [Pipeline] // lock
02:54:40 [Pipeline] }
02:54:40 [Pipeline] // stage
02:54:40 [Pipeline] }
02:54:40 [Pipeline] // node
02:54:40 [Pipeline] End of Pipeline
Actual Results
02:45:54 [Pipeline] {
02:45:54 [Pipeline] stage
02:45:54 [Pipeline] { (test)
02:45:54 [Pipeline] lock
02:45:54 Trying to acquire lock on [testing]
02:45:54 [Pipeline] // lock
02:45:54 [Pipeline] echo
02:45:54 I am in catch block
02:45:54 [Pipeline] echo
02:45:54 java.lang.NullPointerException
02:45:54 [Pipeline] echo
02:45:54 null : stacktrace
02:45:54 [Pipeline] }
02:45:54 [Pipeline] // stage
02:45:54 [Pipeline] }
02:45:54 [Pipeline] // node
02:45:54 [Pipeline] End of Pipeline
Anything else?
get lock by label works, but get lock by resource doesn't work
I tried to print stacktrace, but it seems the "exception" I get contains no stacktrace
Are you interested in contributing a fix?
No response
Interesting. Quantity and select strategy are supported only for labels. But anyway it shall not throw NPE.
I will try to check the NPE and print some better error message.
@clockrun thx for reporting
I noticed a similar issue during the release of a lock with latest release of the plugin (no quantity, no resourceSelectStrategy given)
java.lang.NullPointerException
at org.jenkins.plugins.lockableresources.actions.LockedResourcesBuildAction$ResourcePOJO.<init>(LockedResourcesBuildAction.java:124)
at org.jenkins.plugins.lockableresources.actions.LockedResourcesBuildAction.updateAction(LockedResourcesBuildAction.java:80)
at org.jenkins.plugins.lockableresources.LockStepExecution.proceed(LockStepExecution.java:128)
at org.jenkins.plugins.lockableresources.LockableResourcesManager.unlockNames(LockableResourcesManager.java:653)
at org.jenkins.plugins.lockableresources.LockStepExecution$Callback.finished(LockStepExecution.java:187)
at org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback$TailCall.onSuccess(BodyExecutionCallback.java:118)
at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.receive(CpsBodyExecution.java:375)
at com.cloudbees.groovy.cps.Outcome.resumeFrom(Outcome.java:70)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:149)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:146)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:146)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:423)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:331)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:295)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:97)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
somebody for review #599 ?
Otherwise, I will close it end of this week, thx.