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/causeway.git
The following commit(s) were added to refs/heads/master by this push:
new 45d80a90b6 CAUSEWAY-3675: fixes potential memory leak (sonar)
45d80a90b6 is described below
commit 45d80a90b658358553e749d62c164f3e3d45cb58
Author: Andi Huber <[email protected]>
AuthorDate: Sun Jan 21 06:46:57 2024 +0100
CAUSEWAY-3675: fixes potential memory leak (sonar)
---
.../org/apache/causeway/core/runtime/flushmgmt/FlushMgmt.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git
a/core/runtime/src/main/java/org/apache/causeway/core/runtime/flushmgmt/FlushMgmt.java
b/core/runtime/src/main/java/org/apache/causeway/core/runtime/flushmgmt/FlushMgmt.java
index 69da544788..041939498c 100644
---
a/core/runtime/src/main/java/org/apache/causeway/core/runtime/flushmgmt/FlushMgmt.java
+++
b/core/runtime/src/main/java/org/apache/causeway/core/runtime/flushmgmt/FlushMgmt.java
@@ -28,13 +28,18 @@ public class FlushMgmt {
public static boolean isAutoFlushSuppressed() {
return autoFlushSuppressed.get();
}
- public static void suppressAutoFlush(Runnable runnable) {
- Boolean onEntry = autoFlushSuppressed.get();
+ public static void suppressAutoFlush(final Runnable runnable) {
+ final boolean onEntry = autoFlushSuppressed.get();
try {
autoFlushSuppressed.set(true);
runnable.run();
} finally {
- autoFlushSuppressed.set(onEntry);
+ if(onEntry) {
+ // perhaps superfluous but just in case
+ autoFlushSuppressed.set(true);
+ } else {
+ autoFlushSuppressed.remove();
+ }
}
}