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 2020/01/19 17:28:25 UTC
[isis] branch master updated: ISIS-2223: fix resource leak in
Wormhole
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 f197794 ISIS-2223: fix resource leak in Wormhole
f197794 is described below
commit f197794c05eca9d167475f3755e99d00744bcdcb
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 18:27:36 2020 +0100
ISIS-2223: fix resource leak in Wormhole
---
.../org/apache/isis/core/metamodel/commons/Wormhole.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/commons/Wormhole.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/commons/Wormhole.java
index 77937bb..48a9896 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/commons/Wormhole.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/commons/Wormhole.java
@@ -19,18 +19,14 @@
package org.apache.isis.core.metamodel.commons;
/**
- * Provides a mechanism to avoid infinite loops whereby method A -> method B -> method C -> method A and so on.
+ * Provides a mechanism to avoid infinite loops
+ * whereby method A -> method B -> method C -> method A and so on.
*/
public final class Wormhole {
private Wormhole(){}
- private ThreadLocal<Boolean> inWormhole = new ThreadLocal<Boolean>() {
- @Override
- protected Boolean initialValue() {
- return false;
- }
- };
+ private ThreadLocal<Boolean> inWormhole = ThreadLocal.<Boolean>withInitial(()->Boolean.FALSE);
public void run(final Runnable runnable) {
try {
@@ -40,7 +36,7 @@ public final class Wormhole {
inWormhole.set(true);
runnable.run();
} finally {
- inWormhole.set(false);
+ inWormhole.remove();
}
}