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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-71957] Fix support for Java 21 #570

Merged
merged 2 commits into from
Sep 8, 2023
Merged

[JENKINS-71957] Fix support for Java 21 #570

merged 2 commits into from
Sep 8, 2023

Conversation

alecharp
Copy link
Member

@alecharp alecharp commented Sep 8, 2023

Description

See JENKINS-71957.

When building the plugin with Java 17 and less, everything is fine but once building with Java 20+, there is a NPE occurring in the test.

This is because when testing with invalid setup, the exception is supposed to be printed out. However, the way the exceptions are printed changed. More specifically, the way a lock is acquired in order to print the exceptions. This should have no consequences on any code, as it is internal change of the JVM, but in the current plugin it creates a NPE are the object used to get the lock is a mock which is not properly initialized in the test class.

Testing

I ran mvn clean verify with Java 17 an no issue happened.
I ran mvn clean verify with both Java 20 and 21 and then both JiraCreateReleaseNotesTest.failBuildOnErrorEmptyProjectKey and JiraCreateReleaseNotesTest.failBuildOnErrorEmptyRelease failed with

NullPointer Cannot enter synchronized block because "lock" is null

With this changest, this is not occuring anymore.

To run this and validate the changes, the new Jenkinsfile needs to be used, so a maintainer or an admin must re-open the pull request.

馃毃 Please review the guidelines for contributing to this repository.

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@@ -62,8 +63,7 @@ public class JiraCreateReleaseNotesTest {
@Mock
JiraSite site;

@Mock
private PrintWriter printWriter;
private final PrintWriter printWriter = new PrintWriter(OutputStream.nullOutputStream());
Copy link
Member

Choose a reason for hiding this comment

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

[nit] The only real reason to make this a field in the first place was to use the @Mock annotation on it, so now that @Mock is being deleted this could be inlined and would be arguably more readable that way. But I do not feel strongly either way.

@basil basil requested a review from a team September 8, 2023 18:56
@rantoniuk rantoniuk merged commit 0f08314 into jenkinsci:master Sep 8, 2023
15 checks passed
@alecharp
Copy link
Member Author

Thanks @rantoniuk. Do you think you could release the plugin? Thanks

@alecharp alecharp deleted the fix/java-21-support branch September 12, 2023 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants