diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-09-20 01:44:23 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-09-25 16:15:34 +0200 |
commit | ba2f9affc677d39e2276a2758bfabff61927ba02 (patch) | |
tree | 508f9d0a947746210bd28e728d8c50cbb305c144 | |
parent | a17e05437b0251c4c00b7cbc712d99d68908e122 (diff) | |
download | jgit-ba2f9affc677d39e2276a2758bfabff61927ba02.tar.gz jgit-ba2f9affc677d39e2276a2758bfabff61927ba02.zip |
[errorprone] InterruptTimer#terminate: ensure Thread#join succeeds
See https://errorprone.info/bugpattern/ThreadJoinLoop
Change-Id: Ia67a284311a156c22c18575470ee5fbf734e10cc
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java index 7e46afbc4b..888b8fbb09 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java @@ -104,10 +104,20 @@ public final class InterruptTimer { */ public void terminate() { state.terminate(); + boolean interrupted = false; try { - thread.join(); - } catch (InterruptedException e) { - // + while (true) { + try { + thread.join(); + return; + } catch (InterruptedException e) { + interrupted = true; + } + } + } finally { + if (interrupted) { + Thread.currentThread().interrupt(); + } } } |