From fc8a193a0cc96c422b1be911d36ba6f2a947b358 Mon Sep 17 00:00:00 2001 From: Paul Ferraro Date: Wed, 7 Aug 2024 17:43:04 -0400 Subject: [PATCH] WFLY-19613 Bypass immutability check when redundant. --- .../session/attributes/coarse/CoarseSessionAttributes.java | 3 ++- .../cache/session/attributes/fine/FineSessionAttributes.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/coarse/CoarseSessionAttributes.java b/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/coarse/CoarseSessionAttributes.java index 46b9ac3fb4f0..7970137a06a8 100644 --- a/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/coarse/CoarseSessionAttributes.java +++ b/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/coarse/CoarseSessionAttributes.java @@ -67,7 +67,8 @@ public Object setAttribute(String name, Object value) { @Override public Object getAttribute(String name) { Object value = this.attributes.get(name); - if (!this.immutability.test(value)) { + // Bypass immutability check if session is already dirty + if (!this.dirty.get() && !this.immutability.test(value)) { this.dirty.set(true); } return value; diff --git a/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/fine/FineSessionAttributes.java b/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/fine/FineSessionAttributes.java index 5102360683b2..505d6734bd7a 100644 --- a/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/fine/FineSessionAttributes.java +++ b/clustering/web/cache/src/main/java/org/wildfly/clustering/web/cache/session/attributes/fine/FineSessionAttributes.java @@ -55,8 +55,9 @@ public Object getAttribute(String name) { if (value != null) { // If the object is mutable, we need to mutate this value on close - if (!this.immutability.test(value)) { - synchronized (this.updates) { + synchronized (this.updates) { + // Bypass immutability check if we are already updating this attribute + if (!this.updates.containsKey(name) && !this.immutability.test(value)) { this.updates.put(name, value); } }