aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-12-20 02:23:05 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2020-06-04 23:51:59 +0200
commitaea95b819aeac1cce43e8ad78cef413e3cebaa08 (patch)
treec830cf23dd3011838b30ead480fc9fdaa8a1afdb /org.eclipse.jgit
parented481f96b811c2c50d58f35200657484320621dc (diff)
downloadjgit-aea95b819aeac1cce43e8ad78cef413e3cebaa08.tar.gz
jgit-aea95b819aeac1cce43e8ad78cef413e3cebaa08.zip
Add Git#shutdown for releasing resources held by JGit process
The shutdown method releases - ThreadLocal held by NLS - GlobalBundleCache used by NLS - Executor held by WorkQueue Bug: 437855 Bug: 550529 Change-Id: Icfdccd63668ca90c730ee47a52a17dbd58695ada Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java9
3 files changed, 24 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
index 01306f4129..64314772b7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
@@ -18,6 +18,8 @@ import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.eclipse.jgit.lib.RepositoryCache;
+import org.eclipse.jgit.lib.internal.WorkQueue;
+import org.eclipse.jgit.nls.NLS;
import org.eclipse.jgit.util.FS;
/**
@@ -171,6 +173,15 @@ public class Git implements AutoCloseable {
}
/**
+ * Shutdown JGit and release resources it holds like NLS and thread pools
+ * @since 5.8
+ */
+ public static void shutdown() {
+ WorkQueue.getExecutor().shutdownNow();
+ NLS.clear();
+ }
+
+ /**
* Construct a new {@link org.eclipse.jgit.api.Git} object which can
* interact with the specified git repository.
* <p>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
index 6d4437f4c0..9b556393e2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
@@ -70,4 +70,8 @@ class GlobalBundleCache {
throw new Error(e);
}
}
+
+ static void clear() {
+ cachedBundles.clear();
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java
index daa039d347..d7dd3bee52 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java
@@ -100,6 +100,15 @@ public class NLS {
return b.get(type);
}
+ /**
+ * Release resources held by NLS
+ * @since 5.8
+ */
+ public static void clear() {
+ local.remove();
+ GlobalBundleCache.clear();
+ }
+
private final Locale locale;
private final ConcurrentHashMap<Class, TranslationBundle> map = new ConcurrentHashMap<>();