Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing Arrays.asList with List.of can introduce NullPointerException #642

Merged
merged 1 commit into from Dec 15, 2022

Conversation

jglick
Copy link
Member

@jglick jglick commented Dec 15, 2022

@jglick jglick requested a review from a team as a code owner December 15, 2022 13:09
@jglick jglick added the bug label Dec 15, 2022
"for (def elt : arr) {\n" +
" echo(/iterating on $elt/)\n" +
"}\n", false));
rr.j.assertLogContains("iterating on null", rr.j.buildAndAssertSuccess(p));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reproduced as

java.lang.AssertionError: 
unexpected build status; build log was:
------
Started
[Pipeline] Start of Pipeline
[Pipeline] End of Pipeline
java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:221)
	at java.base/java.util.ImmutableCollections$ListN.<init>(ImmutableCollections.java:432)
	at java.base/java.util.List.of(List.java:1040)
	at org.jenkinsci.plugins.workflow.cps.persistence.IteratorHack.iterator(IteratorHack.java:106)
	at …
	at WorkflowScript.run(WorkflowScript:2)
	at …
Finished: FAILURE

------

Expected: is <SUCCESS>
     but: was <FAILURE>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.jvnet.hudson.test.JenkinsRule.assertBuildStatus(JenkinsRule.java:1438)
	at org.jvnet.hudson.test.JenkinsRule.assertBuildStatus(JenkinsRule.java:1444)
	at org.jvnet.hudson.test.JenkinsRule.buildAndAssertStatus(JenkinsRule.java:1491)
	at org.jvnet.hudson.test.JenkinsRule.buildAndAssertSuccess(JenkinsRule.java:1477)
	at org.jenkinsci.plugins.workflow.cps.persistence.IteratorHackTest.lambda$arrayIterator$4(IteratorHackTest.java:269)

Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved but with a comment so disabling auto merge so the comment can be seen and responded to (even if that is dismissed) and then a merge

@jglick jglick merged commit 4f58de0 into jenkinsci:master Dec 15, 2022
@jglick jglick deleted the List.of branch December 15, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants