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

Harden JarCacheSupport #716

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/hudson/remoting/JarCacheSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@
public void run() {
try {
URL url = retrieve(channel, sum1, sum2);
inprogress.remove(key);
promise.complete(url);
if (inprogress.remove(key, promise)) {
promise.complete(url);
} else {
promise.completeExceptionally(new IllegalStateException("Download is (unexpectedly) no longer in progress"));
}
} catch (ChannelClosedException | RequestAbortedException e) {
// the connection was killed while we were still resolving the file
bailout(e);
Expand All @@ -101,7 +104,7 @@
bailout(e);
} else {
// in other general failures, we aren't retrying
// TODO: or should we?

Check warning on line 107 in src/main/java/hudson/remoting/JarCacheSupport.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: or should we?
promise.completeExceptionally(e);
LOGGER.log(Level.WARNING, String.format("Failed to resolve a jar %016x%016x", sum1, sum2), e);
}
Expand All @@ -112,7 +115,7 @@
* Report a failure of the retrieval and allows another thread to retry.
*/
private void bailout(Throwable e) {
inprogress.remove(key); // this lets another thread to retry later
inprogress.remove(key, promise); // this lets another thread to retry later
promise.completeExceptionally(e); // then tell those who are waiting that we aborted
}
}
Expand Down
Loading