This is an automated email from the ASF dual-hosted git repository.

robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git

commit a4f18f60ade06ef1c9c655ae26e741af258b0fe0
Author: Robert Lazarski <[email protected]>
AuthorDate: Sun May 17 11:55:21 2026 -1000

    AXIS2-5904 Fix version capture ordering and remove dead Date fields
    
    Gemini review found a subtle race: getMaxPolicyVersion() was called
    AFTER calculateEffectivePolicy(), so a concurrent policy update
    between the two calls would stamp the cache with a newer version
    than the policy it contains, causing subsequent calls to miss the
    update. Fix: capture version BEFORE computing the policy.
    
    Also remove dead lastPolicyCalculatedTime fields and unused Date
    imports from both AxisBindingMessage and AxisMessage — all cache
    invalidation now uses the version counter exclusively.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../kernel/src/org/apache/axis2/description/AxisBindingMessage.java | 6 ++----
 modules/kernel/src/org/apache/axis2/description/AxisMessage.java    | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git 
a/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java 
b/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
index 85e3fb54ac..611803bc32 100644
--- a/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
+++ b/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
@@ -33,7 +33,6 @@ import org.apache.neethi.PolicyComponent;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -52,7 +51,6 @@ public class AxisBindingMessage extends AxisDescription {
     private boolean fault = false;
 
     private volatile Policy effectivePolicy = null;
-    private volatile Date lastPolicyCalculatedTime = null;
     private volatile long lastPolicyCalculatedVersion = -1;
 
     public boolean isFault() {
@@ -221,9 +219,9 @@ public class AxisBindingMessage extends AxisDescription {
         if (isPolicyUpdated()) {
             synchronized (this) {
                 if (isPolicyUpdated()) {
+                    final long newVersion = getMaxPolicyVersion();
                     effectivePolicy = calculateEffectivePolicy();
-                    lastPolicyCalculatedTime = new Date();
-                    lastPolicyCalculatedVersion = getMaxPolicyVersion();
+                    lastPolicyCalculatedVersion = newVersion;
                 }
             }
         }
diff --git a/modules/kernel/src/org/apache/axis2/description/AxisMessage.java 
b/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
index 6f6fb88f65..2c2e2e60df 100644
--- a/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
+++ b/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
@@ -37,7 +37,6 @@ import org.apache.ws.commons.schema.XmlSchemaObject;
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
 
 
@@ -67,7 +66,6 @@ public class AxisMessage extends AxisDescription {
     private boolean wrapped = true;
 
     private volatile Policy effectivePolicy = null;
-    private volatile Date lastPolicyCalculatedTime = null;
     private volatile long lastPolicyCalculatedVersion = -1;
 
     public String getMessagePartName() {
@@ -241,9 +239,9 @@ public class AxisMessage extends AxisDescription {
         if (isPolicyUpdated()) {
             synchronized (this) {
                 if (isPolicyUpdated()) {
+                    final long newVersion = getMaxPolicyVersion();
                     effectivePolicy = calculateEffectivePolicy();
-                    lastPolicyCalculatedTime = new Date();
-                    lastPolicyCalculatedVersion = getMaxPolicyVersion();
+                    lastPolicyCalculatedVersion = newVersion;
                 }
             }
         }

Reply via email to