Skip to content

Commit a4f18f6

Browse files
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) <noreply@anthropic.com>
1 parent 18fd259 commit a4f18f6

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import java.util.ArrayList;
3535
import java.util.Collection;
36-
import java.util.Date;
3736
import java.util.HashMap;
3837
import java.util.Map;
3938

@@ -52,7 +51,6 @@ public class AxisBindingMessage extends AxisDescription {
5251
private boolean fault = false;
5352

5453
private volatile Policy effectivePolicy = null;
55-
private volatile Date lastPolicyCalculatedTime = null;
5654
private volatile long lastPolicyCalculatedVersion = -1;
5755

5856
public boolean isFault() {
@@ -221,9 +219,9 @@ public Policy getEffectivePolicy() {
221219
if (isPolicyUpdated()) {
222220
synchronized (this) {
223221
if (isPolicyUpdated()) {
222+
final long newVersion = getMaxPolicyVersion();
224223
effectivePolicy = calculateEffectivePolicy();
225-
lastPolicyCalculatedTime = new Date();
226-
lastPolicyCalculatedVersion = getMaxPolicyVersion();
224+
lastPolicyCalculatedVersion = newVersion;
227225
}
228226
}
229227
}

modules/kernel/src/org/apache/axis2/description/AxisMessage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import javax.xml.namespace.QName;
3838
import java.util.ArrayList;
3939
import java.util.Collection;
40-
import java.util.Date;
4140
import java.util.List;
4241

4342

@@ -67,7 +66,6 @@ public class AxisMessage extends AxisDescription {
6766
private boolean wrapped = true;
6867

6968
private volatile Policy effectivePolicy = null;
70-
private volatile Date lastPolicyCalculatedTime = null;
7169
private volatile long lastPolicyCalculatedVersion = -1;
7270

7371
public String getMessagePartName() {
@@ -241,9 +239,9 @@ public Policy getEffectivePolicy() {
241239
if (isPolicyUpdated()) {
242240
synchronized (this) {
243241
if (isPolicyUpdated()) {
242+
final long newVersion = getMaxPolicyVersion();
244243
effectivePolicy = calculateEffectivePolicy();
245-
lastPolicyCalculatedTime = new Date();
246-
lastPolicyCalculatedVersion = getMaxPolicyVersion();
244+
lastPolicyCalculatedVersion = newVersion;
247245
}
248246
}
249247
}

0 commit comments

Comments
 (0)