-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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 RV_RETURN_VALUE_IGNORED_BAD_PRACTICE
SpotBugs violations
#6025
Fix RV_RETURN_VALUE_IGNORED_BAD_PRACTICE
SpotBugs violations
#6025
Conversation
50bc009
to
c6814e9
Compare
c6814e9
to
d0f5060
Compare
This PR was tested successfully in a passing Windows CI run in #6036. |
…ORED_BAD_PRACTICE
This PR was tested successfully in a passing BOM run in jenkinsci/bom#757. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks—long overdue! Some places I think we wanted to recover gracefully rather than throwing an exception (but silently ignoring the error was bad).
try { | ||
Files.deleteIfExists(file.toPath()); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just log instead? I do not think callers would be expecting an unchecked exception here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few lines above, we convert IOException
into Error
, so I feel like all bets are off with this code path. I made both that path and this one throw UncheckedIOException
, as at least that seems better than Error
.
@@ -1882,12 +1883,8 @@ protected void _run() throws IOException, InstallationStatus { | |||
*/ | |||
protected void replace(File dst, File src) throws IOException { | |||
File bak = Util.changeExtension(dst,".bak"); | |||
bak.delete(); | |||
dst.renameTo(bak); | |||
dst.delete(); // any failure up to here is no big deal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: behavioral change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this seemed like more straightforward behavior to me.
core/src/main/java/hudson/util/io/ReopenableRotatingFileOutputStream.java
Outdated
Show resolved
Hide resolved
core/src/main/java/hudson/util/io/RewindableRotatingFileOutputStream.java
Outdated
Show resolved
Hide resolved
core/src/main/java/jenkins/fingerprints/FileFingerprintStorage.java
Outdated
Show resolved
Hide resolved
public void mkdirs() throws IOException { | ||
Files.createDirectories(Util.fileToPath(file.getParentFile())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically an API change, but there are no plugin consumers of this API, and all the consumers in core were already throwing IOException
anyway.
public void delete() throws IOException { | ||
Files.deleteIfExists(Util.fileToPath(file)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically an API change, but there are no plugin consumers of this API, and all the consumers in core were already throwing IOException
anyway.
public void delete() throws IOException { | ||
Files.deleteIfExists(Util.fileToPath(file)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically an API change that affects 7 plugins at compile-time, but I don't think the addition of the throws
should affect those seven plugins at runtime. I think this is probably fine, but if people feel strongly otherwise I can convert this to an UncheckedIOException
in order to preserve the existing method signature for those 7 plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which plugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jglick Did you have any opinion about this part? This is what I'm the most unsure about, so would be good to hear if you think this is OK or if you'd prefer the UncheckedIOException
approach here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably fine—may cause a compilation error on upgrade, but trivially resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyartifact
ecutest
gerrit-trigger
google-container-registry-auth
jqs-monitoring
nodejs
nuget
xvfb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not do a very close review but looks good.
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! |
…ORED_BAD_PRACTICE
Compatibility with jenkinsci/jenkins#6025
Compatibility with jenkins-2.325 and later (jenkinsci/jenkins#6025)
@@ -96,7 +96,7 @@ public String read() throws IOException { | |||
* Overwrites the file by the given string. | |||
*/ | |||
public void write(String text) throws IOException { | |||
file.getParentFile().mkdirs(); | |||
Files.createDirectories(Util.fileToPath(file.getParentFile())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess createDirectories
was meant here?
Fixes most
RV_RETURN_VALUE_IGNORED_BAD_PRACTICE
, mostly by switching to NIO.2 where possible.Proposed changelog entries
N/A
Proposed upgrade guidelines
N/A
Submitter checklist
Proposed changelog entries
section only if there are breaking changes or other changes which may require extra steps from users during the upgradeDesired reviewers
@StefanSpieker
Maintainer checklist
Before the changes are marked as
ready-for-merge
:Proposed changelog entries
are correctupgrade-guide-needed
label is set and there is aProposed upgrade guidelines
section in the PR title. (example)lts-candidate
to be considered (see query).