From ba2f9affc677d39e2276a2758bfabff61927ba02 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 20 Sep 2023 01:44:23 +0200 Subject: [PATCH] [errorprone] InterruptTimer#terminate: ensure Thread#join succeeds See https://errorprone.info/bugpattern/ThreadJoinLoop Change-Id: Ia67a284311a156c22c18575470ee5fbf734e10cc --- .../org/eclipse/jgit/util/io/InterruptTimer.java | 16 +++++++++++++--- 1 file 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(); + } } } -- 2.39.5