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

Fix DM_DEFAULT_ENCODING SpotBugs violations #6050

Merged
merged 25 commits into from
Dec 23, 2021

Conversation

basil
Copy link
Member

@basil basil commented Dec 11, 2021

Fix DM_DEFAULT_ENCODING SpotBugs violations by explicitly passing in the default character set where possible (or StandardCharsets.UTF_8 for Unix-specific functionality).

Proposed changelog entries

N/A

Proposed upgrade guidelines

N/A

Submitter checklist

  • (If applicable) Jira issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

@basil basil added the skip-changelog Should not be shown in the changelog label Dec 11, 2021
@@ -668,7 +669,7 @@ public void defaultCheckout() throws IOException, InterruptedException {
}
} catch (AbortException e) {
listener.error(e.getMessage());
} catch (InterruptedIOException e) {
} catch (ClosedByInterruptException | InterruptedIOException e) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The change to SCM.java elsewhere in this PR (from traditional Java I/O to NIO.2) means that cancelling a job while SCM checkout is taking place can now throw ClosedByInterruptException as well as InterruptedException and InterruptedIOException. Higher-level code marks the build as ABORTED for InterruptedException and FAILURE for other I/O exceptions, so we convert the ClosedByInterruptException to an InterruptedException here (just as the existing code does for InterruptedIOException) so that the build will be shown as ABORTED (as with the pre-NIO.2 logic).

@basil basil requested a review from a team December 17, 2021 16:09
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

All changes look reasonable. PEMs files should always be UTF-8, same as Unix process files IIRC

@oleg-nenashev oleg-nenashev requested a review from a team December 17, 2021 22:16
@basil basil requested a review from a team December 20, 2021 17:06
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.

At least one spotbugs warning was masking a real issue.

I have looked at the other ones and can not say for certain that all of them are correct but they appear to be. Given this change would then mask the reports of potential issues it may be better to have a few more eyes on this than normal.
To be clear - this change does not introduce any bug - but as the spotbugs warnings are fixed, there is no longer a report to look into something.

cli/src/main/java/hudson/cli/CLIConnectionFactory.java Outdated Show resolved Hide resolved
cli/src/main/java/hudson/cli/CLIConnectionFactory.java Outdated Show resolved Hide resolved
@basil basil requested a review from a team December 20, 2021 18:43
@basil basil added the squash-merge-me Unclean or useless commit history, should be merged only with squash-merge label Dec 20, 2021
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.

I can not say for certain that the changes are all that all correct but they appear to be. Given this change would then mask the reports of potential issues it may be better to have a few more eyes on this than normal.

To be clear - this change does not introduce any bug - but as the spotbugs warnings are fixed, there is no longer a report to look into something.

@basil basil requested a review from a team December 20, 2021 19:11
@basil
Copy link
Member Author

basil commented Dec 20, 2021

it may be better to have a few more eyes on this than normal.

Any other takers?

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

A number of places here where default charset is specified but I think UTF-8 would be more correct. I understand that you are actually making the more conservative change here—retaining existing behavior—but by making the warning go away and adding an explicit call to defaultCharset it makes it look like this was intentional, when generally it was not, thus making it less likely that the code would be corrected in the future compared to just leaving it alone (or adding a suppression annotation).

core/src/main/java/hudson/cli/CLICommand.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/cli/CLICommand.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/cli/CLICommand.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/console/ConsoleNote.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/console/ConsoleNote.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/util/ConsistentHash.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/util/LogTaskListener.java Outdated Show resolved Hide resolved
@basil basil requested a review from jglick December 20, 2021 21:57
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

OK I think.

@basil
Copy link
Member Author

basil commented Dec 20, 2021

OK I think.

Thanks. I'll run this through BOM testing before merging for good measure.

@jglick
Copy link
Member

jglick commented Dec 20, 2021

run this through BOM testing

Would not hurt, though I doubt PCT would catch interesting regressions here since all the CI machines should be using UTF-8 system encoding anyway.

@basil
Copy link
Member Author

basil commented Dec 20, 2021

Would not hurt, though I doubt PCT would catch interesting regressions here since all the CI machines should be using UTF-8 system encoding anyway.

But re-running the tests after I merge the Windows CI PR should cover that.

@jglick
Copy link
Member

jglick commented Dec 21, 2021

Yes that should help. I suspect any actual regressions would be in unusual user configurations not covered by tests.

@basil
Copy link
Member Author

basil commented Dec 22, 2021

This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback. Please see the merge process documentation for more information about the merge process. Thanks!

@basil basil added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Dec 22, 2021
@basil basil merged commit 8a5e309 into jenkinsci:master Dec 23, 2021
@basil basil deleted the DM_DEFAULT_ENCODING branch December 23, 2021 04:34
@jglick
Copy link
Member

jglick commented Dec 15, 2022

places here where default charset is specified but I think UTF-8 would be more correct

OTOH as of https://openjdk.org/jeps/400 it should not matter typically, so choice of Charset.defaultCharset() vs. StandardCharsets.UTF-8 vs. (where permitted without deprecation warning!) omitting a Charset or String charset argument would be a matter of style and legibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback skip-changelog Should not be shown in the changelog squash-merge-me Unclean or useless commit history, should be merged only with squash-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants