You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2022/03/21 15:09:59 UTC
[isis] branch master updated: ISIS-2978: supposedly fixes ContextClassLoader issues
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 098cb10 ISIS-2978: supposedly fixes ContextClassLoader issues
098cb10 is described below
commit 098cb10a75f98dc577016720bbf9e05642d76077
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Mar 21 16:09:46 2022 +0100
ISIS-2978: supposedly fixes ContextClassLoader issues
---
.../internal/concurrent/_ConcurrentTask.java | 35 +++++++++++++++++-----
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/commons/src/main/java/org/apache/isis/commons/internal/concurrent/_ConcurrentTask.java b/commons/src/main/java/org/apache/isis/commons/internal/concurrent/_ConcurrentTask.java
index 4e63207..2cbe937 100644
--- a/commons/src/main/java/org/apache/isis/commons/internal/concurrent/_ConcurrentTask.java
+++ b/commons/src/main/java/org/apache/isis/commons/internal/concurrent/_ConcurrentTask.java
@@ -81,13 +81,17 @@ public abstract class _ConcurrentTask<T> implements Runnable {
@Override
public final void run() {
- preCall();
- try {
- val completedWith = innerCall();
- postCall(completedWith, /*failedWith*/ null);
- } catch (Throwable e) {
- postCall(/*completedWith*/ null, e);
- }
+ runWithContextClassLoader(getClass().getClassLoader(), ()->{
+
+ preCall();
+ try {
+ val completedWith = innerCall();
+ postCall(completedWith, /*failedWith*/ null);
+ } catch (Throwable e) {
+ postCall(/*completedWith*/ null, e);
+ }
+
+ });
}
@@ -176,4 +180,21 @@ public abstract class _ConcurrentTask<T> implements Runnable {
};
}
+ // -- HELPER
+
+ /**
+ * [ISIS-2978]
+ * see https://stackoverflow.com/a/36228195/9269480
+ */
+ private void runWithContextClassLoader(final ClassLoader classLoader, final Runnable runnable) {
+ val originalContextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ runnable.run();
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalContextClassLoader);
+ }
+ }
+
+
}