diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2022-10-27 20:31:31 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2022-10-27 20:31:58 +0200 |
commit | 924491d4df62b1e43e9458f922da6ef4f3b3df30 (patch) | |
tree | 7810b67bdc5f586944a7d0a68a7f39db6135427b | |
parent | 035e0e23f251fdb766a6630509bcf342efb8b3ad (diff) | |
download | jgit-924491d4df62b1e43e9458f922da6ef4f3b3df30.tar.gz jgit-924491d4df62b1e43e9458f922da6ef4f3b3df30.zip |
Ignore IllegalStateException if JVM is already shutting down
Trying to register/unregister a shutdown hook when the JVM is already in
shutdown throws an IllegalStateException. Ignore this exception since we
can't do anything about it.
Bug: 580953
Change-Id: I8fc6fdd5585837c81ad0ebd6944430856556d90e
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index eff2b97eab..e0de9b2737 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -300,14 +300,19 @@ public abstract class FS { static { // Shut down the SAVE_RUNNER on System.exit() - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - try { - SAVE_RUNNER.shutdownNow(); - SAVE_RUNNER.awaitTermination(100, TimeUnit.MILLISECONDS); - } catch (Exception e) { - // Ignore; we're shutting down - } - })); + try { + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + try { + SAVE_RUNNER.shutdownNow(); + SAVE_RUNNER.awaitTermination(100, + TimeUnit.MILLISECONDS); + } catch (Exception e) { + // Ignore; we're shutting down + } + })); + } catch (IllegalStateException e) { + // ignore - may fail if shutdown is already in progress + } } /** |