From 5a29628a9e59fc9f53f3ce3b11e45033fc544913 Mon Sep 17 00:00:00 2001 From: Vladimir Mutafov Date: Wed, 12 Jan 2022 22:51:18 +0200 Subject: [PATCH 1/3] chore: change stack id to integer and remove redundant code in ThreadContextFacade --- .../api/context/ThreadContextFacade.java | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java b/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java index de727979d75..1f7660585ab 100644 --- a/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java +++ b/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java @@ -27,32 +27,32 @@ public class ThreadContextFacade { private static final Logger logger = LoggerFactory.getLogger(ThreadContextFacade.class); - private static final ThreadLocal>> STACKED_CONTEXT = new ThreadLocal>>(); + private static final ThreadLocal>> STACKED_CONTEXT = new ThreadLocal<>(); - private static final ThreadLocal>> STACKED_CLOSEABLES = new ThreadLocal>>(); + private static final ThreadLocal>> STACKED_CLOSEABLES = new ThreadLocal<>(); private static final AtomicLong UUID_GENERATOR = new AtomicLong(Long.MIN_VALUE); - private static final ThreadLocal STACK_ID = new ThreadLocal(); + private static final ThreadLocal STACK_ID = new ThreadLocal<>(); /** * Initializes the context. This has to be called at the very first (as possible) place at the service entry point * */ - public static final void setUp() { + public static void setUp() { if (STACKED_CONTEXT.get() == null || STACKED_CONTEXT.get().size() == 0) { - STACKED_CONTEXT.set(new HashMap>()); + STACKED_CONTEXT.set(new HashMap<>()); } if (STACKED_CLOSEABLES.get() == null || STACKED_CLOSEABLES.get().size() == 0) { - STACKED_CLOSEABLES.set(new HashMap>()); + STACKED_CLOSEABLES.set(new HashMap<>()); } if (STACK_ID.get() == null) { STACK_ID.set(0); } else { STACK_ID.set(STACK_ID.get() + 1); } - STACKED_CONTEXT.get().put(STACK_ID.get() + "", new HashMap()); - STACKED_CLOSEABLES.get().put(STACK_ID.get() + "", new HashMap()); + STACKED_CONTEXT.get().put(STACK_ID.get(), new HashMap<>()); + STACKED_CLOSEABLES.get().put(STACK_ID.get(), new HashMap<>()); logger.trace("Scripting context {} has been set up", Thread.currentThread().hashCode()); } @@ -61,16 +61,16 @@ public static final void setUp() { * IMPORTANT! This have to be added at the finally block to clean up objects after the execution of the service. * */ - public static final void tearDown() { + public static void tearDown() { if (STACK_ID.get() == null) { return; } int stackId = STACK_ID.get(); if (STACKED_CONTEXT.get() != null && STACKED_CONTEXT.get().size() > 0) { - STACKED_CONTEXT.get().get(STACK_ID.get() + "").clear(); + STACKED_CONTEXT.get().get(STACK_ID.get()).clear(); } if (STACKED_CLOSEABLES.get() != null && STACKED_CLOSEABLES.get().size() > 0) { - Map CLOSEABLES = STACKED_CLOSEABLES.get().get(STACK_ID.get() + ""); + Map CLOSEABLES = STACKED_CLOSEABLES.get().get(STACK_ID.get()); for (Entry closeable : CLOSEABLES.entrySet()) { try { logger.error("Object of type {} from the context {} has not been closed properly.", closeable.getValue().getClass().getCanonicalName(), Thread.currentThread().hashCode()); @@ -79,7 +79,7 @@ public static final void tearDown() { logger.error(e.getMessage(), e); } } - STACKED_CLOSEABLES.get().get(STACK_ID.get() + "").clear(); + STACKED_CLOSEABLES.get().get(STACK_ID.get()).clear(); } if (stackId == 0) { STACKED_CONTEXT.remove(); @@ -99,9 +99,11 @@ public static final void tearDown() { * @throws ContextException * in case of an error */ - public static final Object get(String key) throws ContextException { + public static Object get(String key) throws ContextException { checkContext(); - return STACKED_CONTEXT.get().get(STACK_ID.get() + "").get(key); + Map> stackedContext = STACKED_CONTEXT.get(); + Map currentStack = stackedContext.get(STACK_ID.get()); + return currentStack.get(key); } /** @@ -113,7 +115,7 @@ public static final Object get(String key) throws ContextException { * @throws ContextException * in case of an error */ - public static final String set(Object value) throws ContextException { + public static String set(Object value) throws ContextException { final String uuid = generateObjectId(); set(uuid, value); return uuid; @@ -131,9 +133,9 @@ public static final String set(Object value) throws ContextException { * @throws ContextException * in case of an error */ - public static final void set(String key, Object value) throws ContextException { + public static void set(String key, Object value) throws ContextException { checkContext(); - STACKED_CONTEXT.get().get(STACK_ID.get() + "").put(key, value); + STACKED_CONTEXT.get().get(STACK_ID.get()).put(key, value); logger.trace("Context object has been added to {} with key {}", Thread.currentThread().hashCode(), key); } @@ -145,10 +147,10 @@ public static final void set(String key, Object value) throws ContextException { * @throws ContextException * in case of an error */ - public static final void remove(String key) throws ContextException { + public static void remove(String key) throws ContextException { checkContext(); - STACKED_CONTEXT.get().get(STACK_ID.get() + "").remove(key); - logger.trace("Context object has been removed - key {}", Thread.currentThread().hashCode(), key); + STACKED_CONTEXT.get().get(STACK_ID.get()).remove(key); + logger.trace("Context object has been removed - key {}", key); } /** @@ -186,9 +188,9 @@ private static String generateObjectId() { * * @param closeable the closeable object */ - public static final void addCloseable(AutoCloseable closeable) { + public static void addCloseable(AutoCloseable closeable) { if (STACKED_CLOSEABLES.get() != null) { - STACKED_CLOSEABLES.get().get(STACK_ID.get() + "").put(STACK_ID.get() + "_" + closeable.hashCode(), closeable); + STACKED_CLOSEABLES.get().get(STACK_ID.get()).put(STACK_ID.get() + "_" + closeable.hashCode(), closeable); logger.trace("Closeable object has been added to {} with hash {}", Thread.currentThread().hashCode(), closeable.hashCode()); } } @@ -198,10 +200,10 @@ public static final void addCloseable(AutoCloseable closeable) { * * @param closeable the closeable object */ - public static final void removeCloseable(AutoCloseable closeable) { + public static void removeCloseable(AutoCloseable closeable) { if (STACKED_CLOSEABLES.get() != null) { - STACKED_CLOSEABLES.get().get(STACK_ID.get() + "").remove(STACK_ID.get() + "_" + closeable.hashCode()); - logger.trace("Closeable object has been removed - hash {}", Thread.currentThread().hashCode(), closeable.hashCode()); + STACKED_CLOSEABLES.get().get(STACK_ID.get()).remove(STACK_ID.get() + "_" + closeable.hashCode()); + logger.trace("Closeable object has been removed - hash {}", closeable.hashCode()); } } } From 316cef1a1acfa1747228d5b64f7191b767150c99 Mon Sep 17 00:00:00 2001 From: Vladimir Mutafov Date: Wed, 12 Jan 2022 23:55:20 +0200 Subject: [PATCH 2/3] fix: preserve parent stack objects when creating a new one --- .../api/context/ThreadContextFacade.java | 75 ++++++++++++++----- 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java b/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java index 1f7660585ab..5e993755b60 100644 --- a/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java +++ b/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java @@ -11,7 +11,9 @@ */ package org.eclipse.dirigible.commons.api.context; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicLong; @@ -40,37 +42,54 @@ public class ThreadContextFacade { * */ public static void setUp() { - if (STACKED_CONTEXT.get() == null || STACKED_CONTEXT.get().size() == 0) { + if (stackedContextIsEmpty()) { STACKED_CONTEXT.set(new HashMap<>()); } - if (STACKED_CLOSEABLES.get() == null || STACKED_CLOSEABLES.get().size() == 0) { + if (stackedCloseablesIsEmpty()) { STACKED_CLOSEABLES.set(new HashMap<>()); } - if (STACK_ID.get() == null) { + + Integer currentStackId = STACK_ID.get(); + if (currentStackId == null) { STACK_ID.set(0); } else { - STACK_ID.set(STACK_ID.get() + 1); + STACK_ID.set(currentStackId + 1); + } - STACKED_CONTEXT.get().put(STACK_ID.get(), new HashMap<>()); + + STACKED_CONTEXT.get().put(STACK_ID.get(), collectParentObjects()); STACKED_CLOSEABLES.get().put(STACK_ID.get(), new HashMap<>()); logger.trace("Scripting context {} has been set up", Thread.currentThread().hashCode()); } + private static Map collectParentObjects() { + Map allParentObjects = new HashMap<>(); + + for (int parentStackId = STACK_ID.get() - 1; parentStackId >= 0; parentStackId -= 1) { + Map parentStackObjects = STACKED_CONTEXT.get().get(parentStackId); + allParentObjects.putAll(parentStackObjects); + } + + return allParentObjects; + } + /** * IMPORTANT! This have to be added at the finally block to clean up objects after the execution of the service. * */ public static void tearDown() { - if (STACK_ID.get() == null) { - return; - } - int stackId = STACK_ID.get(); - if (STACKED_CONTEXT.get() != null && STACKED_CONTEXT.get().size() > 0) { - STACKED_CONTEXT.get().get(STACK_ID.get()).clear(); + Integer stackId = STACK_ID.get(); + if (stackId == null) { + return; + } + + if (stackedContextIsNotEmpty()) { + STACKED_CONTEXT.get().get(stackId).clear(); } - if (STACKED_CLOSEABLES.get() != null && STACKED_CLOSEABLES.get().size() > 0) { - Map CLOSEABLES = STACKED_CLOSEABLES.get().get(STACK_ID.get()); + + if (stackedCloseablesIsNotEmpty()) { + Map CLOSEABLES = STACKED_CLOSEABLES.get().get(stackId); for (Entry closeable : CLOSEABLES.entrySet()) { try { logger.error("Object of type {} from the context {} has not been closed properly.", closeable.getValue().getClass().getCanonicalName(), Thread.currentThread().hashCode()); @@ -79,8 +98,9 @@ public static void tearDown() { logger.error(e.getMessage(), e); } } - STACKED_CLOSEABLES.get().get(STACK_ID.get()).clear(); + STACKED_CLOSEABLES.get().get(stackId).clear(); } + if (stackId == 0) { STACKED_CONTEXT.remove(); STACKED_CLOSEABLES.remove(); @@ -142,10 +162,8 @@ public static void set(String key, Object value) throws ContextException { /** * Remove a context scripting object. * - * @param key - * the key - * @throws ContextException - * in case of an error + * @param key the key + * @throws ContextException in case of an error */ public static void remove(String key) throws ContextException { checkContext(); @@ -153,6 +171,7 @@ public static void remove(String key) throws ContextException { logger.trace("Context object has been removed - key {}", key); } + /** * Check context. * @@ -206,4 +225,24 @@ public static void removeCloseable(AutoCloseable closeable) { logger.trace("Closeable object has been removed - hash {}", closeable.hashCode()); } } + + private static boolean stackedContextIsEmpty() { + Map> stackedContext = STACKED_CONTEXT.get(); + return stackedContext == null || stackedContext.isEmpty(); + } + + private static boolean stackedContextIsNotEmpty() { + Map> stackedContext = STACKED_CONTEXT.get(); + return stackedContext != null && !stackedContext.isEmpty(); + } + + private static boolean stackedCloseablesIsEmpty() { + Map> stackedCloseables = STACKED_CLOSEABLES.get(); + return stackedCloseables == null || stackedCloseables.isEmpty(); + } + + private static boolean stackedCloseablesIsNotEmpty() { + Map> stackedCloseables = STACKED_CLOSEABLES.get(); + return stackedCloseables != null && !stackedCloseables.isEmpty(); + } } From 6b30c6cc3afc45f16d9a3887b4579e4214cf3311 Mon Sep 17 00:00:00 2001 From: Vladimir Mutafov Date: Wed, 12 Jan 2022 23:58:11 +0200 Subject: [PATCH 3/3] chore: format code --- .../api/context/ThreadContextFacade.java | 384 +++++++++--------- 1 file changed, 187 insertions(+), 197 deletions(-) diff --git a/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java b/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java index 5e993755b60..17f96e1de52 100644 --- a/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java +++ b/modules/commons/commons-api/src/main/java/org/eclipse/dirigible/commons/api/context/ThreadContextFacade.java @@ -27,213 +27,203 @@ */ public class ThreadContextFacade { - private static final Logger logger = LoggerFactory.getLogger(ThreadContextFacade.class); - - private static final ThreadLocal>> STACKED_CONTEXT = new ThreadLocal<>(); - - private static final ThreadLocal>> STACKED_CLOSEABLES = new ThreadLocal<>(); - - private static final AtomicLong UUID_GENERATOR = new AtomicLong(Long.MIN_VALUE); - - private static final ThreadLocal STACK_ID = new ThreadLocal<>(); - - /** - * Initializes the context. This has to be called at the very first (as possible) place at the service entry point - * - */ - public static void setUp() { - if (stackedContextIsEmpty()) { - STACKED_CONTEXT.set(new HashMap<>()); - } - if (stackedCloseablesIsEmpty()) { - STACKED_CLOSEABLES.set(new HashMap<>()); - } - - Integer currentStackId = STACK_ID.get(); - if (currentStackId == null) { - STACK_ID.set(0); - } else { - STACK_ID.set(currentStackId + 1); - - } - - STACKED_CONTEXT.get().put(STACK_ID.get(), collectParentObjects()); - STACKED_CLOSEABLES.get().put(STACK_ID.get(), new HashMap<>()); - - logger.trace("Scripting context {} has been set up", Thread.currentThread().hashCode()); - } - - private static Map collectParentObjects() { - Map allParentObjects = new HashMap<>(); - - for (int parentStackId = STACK_ID.get() - 1; parentStackId >= 0; parentStackId -= 1) { - Map parentStackObjects = STACKED_CONTEXT.get().get(parentStackId); - allParentObjects.putAll(parentStackObjects); - } - - return allParentObjects; - } - - /** - * IMPORTANT! This have to be added at the finally block to clean up objects after the execution of the service. - * - */ - public static void tearDown() { + private static final Logger logger = LoggerFactory.getLogger(ThreadContextFacade.class); + + private static final ThreadLocal>> STACKED_CONTEXT = new ThreadLocal<>(); + + private static final ThreadLocal>> STACKED_CLOSEABLES = new ThreadLocal<>(); + + private static final AtomicLong UUID_GENERATOR = new AtomicLong(Long.MIN_VALUE); + + private static final ThreadLocal STACK_ID = new ThreadLocal<>(); + + /** + * Initializes the context. This has to be called at the very first (as possible) place at the service entry point + */ + public static void setUp() { + if (stackedContextIsEmpty()) { + STACKED_CONTEXT.set(new HashMap<>()); + } + if (stackedCloseablesIsEmpty()) { + STACKED_CLOSEABLES.set(new HashMap<>()); + } + + Integer currentStackId = STACK_ID.get(); + if (currentStackId == null) { + STACK_ID.set(0); + } else { + STACK_ID.set(currentStackId + 1); + + } + + STACKED_CONTEXT.get().put(STACK_ID.get(), collectParentObjects()); + STACKED_CLOSEABLES.get().put(STACK_ID.get(), new HashMap<>()); + + logger.trace("Scripting context {} has been set up", Thread.currentThread().hashCode()); + } + + private static Map collectParentObjects() { + Map allParentObjects = new HashMap<>(); + + for (int parentStackId = STACK_ID.get() - 1; parentStackId >= 0; parentStackId -= 1) { + Map parentStackObjects = STACKED_CONTEXT.get().get(parentStackId); + allParentObjects.putAll(parentStackObjects); + } + + return allParentObjects; + } + + /** + * IMPORTANT! This have to be added at the finally block to clean up objects after the execution of the service. + */ + public static void tearDown() { Integer stackId = STACK_ID.get(); - if (stackId == null) { + if (stackId == null) { return; } - if (stackedContextIsNotEmpty()) { - STACKED_CONTEXT.get().get(stackId).clear(); - } - - if (stackedCloseablesIsNotEmpty()) { - Map CLOSEABLES = STACKED_CLOSEABLES.get().get(stackId); - for (Entry closeable : CLOSEABLES.entrySet()) { - try { - logger.error("Object of type {} from the context {} has not been closed properly.", closeable.getValue().getClass().getCanonicalName(), Thread.currentThread().hashCode()); - closeable.getValue().close(); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } - } - STACKED_CLOSEABLES.get().get(stackId).clear(); - } - - if (stackId == 0) { - STACKED_CONTEXT.remove(); - STACKED_CLOSEABLES.remove(); - } - STACK_ID.set(stackId - 1); - - logger.trace("Scripting context {} has been torn down", Thread.currentThread().hashCode()); - } - - /** - * Get a context scripting object. - * - * @param key - * the key - * @return the value by this key - * @throws ContextException - * in case of an error - */ - public static Object get(String key) throws ContextException { - checkContext(); - Map> stackedContext = STACKED_CONTEXT.get(); - Map currentStack = stackedContext.get(STACK_ID.get()); - return currentStack.get(key); - } - - /** - * Set a context scripting object. - * - * @param value - * the value - * @return the UUID of the object - * @throws ContextException - * in case of an error - */ - public static String set(Object value) throws ContextException { - final String uuid = generateObjectId(); - set(uuid, value); - return uuid; - } - - /** - * Set a context scripting object. If object with - * with this key exists, it will be replaced with - * the new object - * - * @param key - * the key - * @param value - * the value - * @throws ContextException - * in case of an error - */ - public static void set(String key, Object value) throws ContextException { - checkContext(); - STACKED_CONTEXT.get().get(STACK_ID.get()).put(key, value); - logger.trace("Context object has been added to {} with key {}", Thread.currentThread().hashCode(), key); - } - - /** - * Remove a context scripting object. - * - * @param key the key - * @throws ContextException in case of an error - */ - public static void remove(String key) throws ContextException { - checkContext(); - STACKED_CONTEXT.get().get(STACK_ID.get()).remove(key); - logger.trace("Context object has been removed - key {}", key); - } - - - /** - * Check context. - * - * @throws ContextException - * the context exception - */ - private static void checkContext() throws ContextException { - if (STACKED_CONTEXT.get() == null) { - throw new ContextException("Context has not been initialized"); - } - } - - /** - * Check whether the facade is valid. - * - * @return yes, if it is valid - */ - public static boolean isValid() { - return (STACKED_CONTEXT.get() != null); - } - - /** - * Generate object id. - * - * @return the string - */ - private static String generateObjectId() { - return Long.toString(UUID_GENERATOR.incrementAndGet(), Character.MAX_RADIX); - } - - /** - * Add a closeable object to the map - * - * @param closeable the closeable object - */ - public static void addCloseable(AutoCloseable closeable) { - if (STACKED_CLOSEABLES.get() != null) { - STACKED_CLOSEABLES.get().get(STACK_ID.get()).put(STACK_ID.get() + "_" + closeable.hashCode(), closeable); - logger.trace("Closeable object has been added to {} with hash {}", Thread.currentThread().hashCode(), closeable.hashCode()); - } - } - - /** - * Remove a closeable object. - * - * @param closeable the closeable object - */ - public static void removeCloseable(AutoCloseable closeable) { - if (STACKED_CLOSEABLES.get() != null) { - STACKED_CLOSEABLES.get().get(STACK_ID.get()).remove(STACK_ID.get() + "_" + closeable.hashCode()); - logger.trace("Closeable object has been removed - hash {}", closeable.hashCode()); - } - } + if (stackedContextIsNotEmpty()) { + STACKED_CONTEXT.get().get(stackId).clear(); + } + + if (stackedCloseablesIsNotEmpty()) { + Map CLOSEABLES = STACKED_CLOSEABLES.get().get(stackId); + for (Entry closeable : CLOSEABLES.entrySet()) { + try { + logger.error("Object of type {} from the context {} has not been closed properly.", closeable.getValue().getClass().getCanonicalName(), Thread.currentThread().hashCode()); + closeable.getValue().close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } + STACKED_CLOSEABLES.get().get(stackId).clear(); + } + + if (stackId == 0) { + STACKED_CONTEXT.remove(); + STACKED_CLOSEABLES.remove(); + } + STACK_ID.set(stackId - 1); + + logger.trace("Scripting context {} has been torn down", Thread.currentThread().hashCode()); + } + + /** + * Get a context scripting object. + * + * @param key the key + * @return the value by this key + * @throws ContextException in case of an error + */ + public static Object get(String key) throws ContextException { + checkContext(); + Map> stackedContext = STACKED_CONTEXT.get(); + Map currentStack = stackedContext.get(STACK_ID.get()); + return currentStack.get(key); + } + + /** + * Set a context scripting object. + * + * @param value the value + * @return the UUID of the object + * @throws ContextException in case of an error + */ + public static String set(Object value) throws ContextException { + final String uuid = generateObjectId(); + set(uuid, value); + return uuid; + } + + /** + * Set a context scripting object. If object with + * with this key exists, it will be replaced with + * the new object + * + * @param key the key + * @param value the value + * @throws ContextException in case of an error + */ + public static void set(String key, Object value) throws ContextException { + checkContext(); + STACKED_CONTEXT.get().get(STACK_ID.get()).put(key, value); + logger.trace("Context object has been added to {} with key {}", Thread.currentThread().hashCode(), key); + } + + /** + * Remove a context scripting object. + * + * @param key the key + * @throws ContextException in case of an error + */ + public static void remove(String key) throws ContextException { + checkContext(); + STACKED_CONTEXT.get().get(STACK_ID.get()).remove(key); + logger.trace("Context object has been removed - key {}", key); + } + + + /** + * Check context. + * + * @throws ContextException the context exception + */ + private static void checkContext() throws ContextException { + if (STACKED_CONTEXT.get() == null) { + throw new ContextException("Context has not been initialized"); + } + } + + /** + * Check whether the facade is valid. + * + * @return yes, if it is valid + */ + public static boolean isValid() { + return (STACKED_CONTEXT.get() != null); + } + + /** + * Generate object id. + * + * @return the string + */ + private static String generateObjectId() { + return Long.toString(UUID_GENERATOR.incrementAndGet(), Character.MAX_RADIX); + } + + /** + * Add a closeable object to the map + * + * @param closeable the closeable object + */ + public static void addCloseable(AutoCloseable closeable) { + if (STACKED_CLOSEABLES.get() != null) { + STACKED_CLOSEABLES.get().get(STACK_ID.get()).put(STACK_ID.get() + "_" + closeable.hashCode(), closeable); + logger.trace("Closeable object has been added to {} with hash {}", Thread.currentThread().hashCode(), closeable.hashCode()); + } + } + + /** + * Remove a closeable object. + * + * @param closeable the closeable object + */ + public static void removeCloseable(AutoCloseable closeable) { + if (STACKED_CLOSEABLES.get() != null) { + STACKED_CLOSEABLES.get().get(STACK_ID.get()).remove(STACK_ID.get() + "_" + closeable.hashCode()); + logger.trace("Closeable object has been removed - hash {}", closeable.hashCode()); + } + } private static boolean stackedContextIsEmpty() { Map> stackedContext = STACKED_CONTEXT.get(); return stackedContext == null || stackedContext.isEmpty(); } - private static boolean stackedContextIsNotEmpty() { - Map> stackedContext = STACKED_CONTEXT.get(); - return stackedContext != null && !stackedContext.isEmpty(); + private static boolean stackedContextIsNotEmpty() { + Map> stackedContext = STACKED_CONTEXT.get(); + return stackedContext != null && !stackedContext.isEmpty(); } private static boolean stackedCloseablesIsEmpty() {