From 40ccf80c7f0ea0a04ef3163d13114024ee8713e9 Mon Sep 17 00:00:00 2001 From: Zoe Gidiere Date: Sat, 12 Oct 2024 00:58:08 -0600 Subject: [PATCH] Optimization when Terra Profiler is not running Do not set Profiler SAFE Threadlocal var when profiler is not running but ensure it is set to false after the profiler stops to ensure consistent behavior --- .../src/main/java/com/dfsek/terra/profiler/ProfilerImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/profiler/ProfilerImpl.java b/common/implementation/base/src/main/java/com/dfsek/terra/profiler/ProfilerImpl.java index 4e419f883..81519cac8 100644 --- a/common/implementation/base/src/main/java/com/dfsek/terra/profiler/ProfilerImpl.java +++ b/common/implementation/base/src/main/java/com/dfsek/terra/profiler/ProfilerImpl.java @@ -57,7 +57,7 @@ public class ProfilerImpl implements Profiler { Stack stack = THREAD_STACK.get(); stack.push(new Frame(stack.isEmpty() ? frame : stack.peek().getId() + "." + frame)); } else SAFE.set(false); - } else SAFE.set(false); + } } @Override @@ -99,6 +99,7 @@ public class ProfilerImpl implements Profiler { public void stop() { logger.info("Stopping Terra profiler"); running = false; + SAFE.set(false); } @Override