Skip to content

Commit 349a419

Browse files
brunoborgesCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent b9ad1c6 commit 349a419

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

java/src/main/java/com/github/copilot/CopilotClient.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,21 @@ public void close() {
926926
}
927927

928928
private void shutdownOwnedExecutor() {
929-
if (ownedExecutor != null) {
930-
ownedExecutor.shutdown();
929+
if (ownedExecutor == null) {
930+
return;
931+
}
932+
933+
ownedExecutor.shutdown();
934+
try {
935+
if (!ownedExecutor.awaitTermination(AUTOCLOSEABLE_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
936+
LOG.log(Level.FINE, "Owned executor did not terminate within {0} seconds; forcing shutdown.",
937+
AUTOCLOSEABLE_TIMEOUT_SECONDS);
938+
ownedExecutor.shutdownNow();
939+
}
940+
} catch (InterruptedException e) {
941+
ownedExecutor.shutdownNow();
942+
Thread.currentThread().interrupt();
943+
LOG.log(Level.FINE, "Interrupted while waiting for owned executor to terminate", e);
931944
}
932945
}
933946

0 commit comments

Comments
 (0)