This is an automated email from the ASF dual-hosted git repository. billblough pushed a commit to branch AXIS2-5904 in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit c121777003ecaea924af7e0f3b845c0a8a849339 Author: Andreas Veithen <veit...@apache.org> AuthorDate: Fri Jan 12 00:55:54 2018 +0000 Tentative solution for AXIS2-5904. --- .../axis2/description/AxisBindingMessage.java | 4 +-- .../org/apache/axis2/description/AxisMessage.java | 5 ++-- .../apache/axis2/description/OpaqueInstant.java | 35 ++++++++++++++++++++++ .../apache/axis2/description/PolicySubject.java | 17 +++++------ 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java b/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java index e358cbb..87b374e 100644 --- a/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java +++ b/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java @@ -53,7 +53,7 @@ public class AxisBindingMessage extends AxisDescription { private boolean fault = false; private volatile Policy effectivePolicy = null; - private volatile Date lastPolicyCalculatedTime = null; + private volatile OpaqueInstant lastPolicyCalculatedTime = null; public boolean isFault() { return fault; @@ -225,7 +225,7 @@ public class AxisBindingMessage extends AxisDescription { synchronized (this) { if (lastPolicyCalculatedTime == null || isPolicyUpdated()) { effectivePolicy = calculateEffectivePolicy(); - lastPolicyCalculatedTime = new Date(); + lastPolicyCalculatedTime = new OpaqueInstant(); } } } diff --git a/modules/kernel/src/org/apache/axis2/description/AxisMessage.java b/modules/kernel/src/org/apache/axis2/description/AxisMessage.java index f7a1d07..eb8d85c 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,7 @@ public class AxisMessage extends AxisDescription { private boolean wrapped = true; private volatile Policy effectivePolicy = null; - private volatile Date lastPolicyCalculatedTime = null; + private volatile OpaqueInstant lastPolicyCalculatedTime = null; public String getMessagePartName() { return messagePartName; @@ -241,7 +240,7 @@ public class AxisMessage extends AxisDescription { synchronized (this) { if (lastPolicyCalculatedTime == null || isPolicyUpdated()) { effectivePolicy = calculateEffectivePolicy(); - lastPolicyCalculatedTime = new Date(); + lastPolicyCalculatedTime = new OpaqueInstant(); } } } diff --git a/modules/kernel/src/org/apache/axis2/description/OpaqueInstant.java b/modules/kernel/src/org/apache/axis2/description/OpaqueInstant.java new file mode 100644 index 0000000..b28e024 --- /dev/null +++ b/modules/kernel/src/org/apache/axis2/description/OpaqueInstant.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.axis2.description; + +import java.util.concurrent.atomic.AtomicInteger; + +public final class OpaqueInstant { + private static final AtomicInteger nextSequence = new AtomicInteger(); + + private final int sequence; + + public OpaqueInstant() { + sequence = nextSequence.getAndIncrement(); + } + + public boolean after(OpaqueInstant when) { + return sequence > when.sequence; + } +} diff --git a/modules/kernel/src/org/apache/axis2/description/PolicySubject.java b/modules/kernel/src/org/apache/axis2/description/PolicySubject.java index 49e0b59..3bcaab0 100644 --- a/modules/kernel/src/org/apache/axis2/description/PolicySubject.java +++ b/modules/kernel/src/org/apache/axis2/description/PolicySubject.java @@ -25,13 +25,12 @@ import org.apache.neethi.PolicyComponent; import org.apache.neethi.PolicyReference; import java.util.Collection; -import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.concurrent.ConcurrentHashMap; public class PolicySubject { - private Date lastUpdatedTime = new Date(); + private OpaqueInstant lastUpdatedTime = new OpaqueInstant(); private ConcurrentHashMap<String, PolicyComponent> attachedPolicyComponents = new ConcurrentHashMap<String, PolicyComponent>(); @@ -49,7 +48,7 @@ public class PolicySubject { public void attachPolicyReference(PolicyReference reference) { attachedPolicyComponents.put(reference.getURI(), reference); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public void attachPolicyComponents(List<PolicyComponent> policyComponents) { @@ -74,7 +73,7 @@ public class PolicySubject { public void attachPolicyComponent(String key, PolicyComponent policyComponent) { attachedPolicyComponents.put(key, policyComponent); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public PolicyComponent getAttachedPolicyComponent(String key) { @@ -94,24 +93,24 @@ public class PolicySubject { "policy doesn't have a name or an id "); } attachedPolicyComponents.put(key, policy); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public void detachPolicyComponent(String key) { attachedPolicyComponents.remove(key); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } public void clear() { attachedPolicyComponents.clear(); - setLastUpdatedTime(new Date()); + setLastUpdatedTime(new OpaqueInstant()); } - public Date getLastUpdatedTime() { + public OpaqueInstant getLastUpdatedTime() { return lastUpdatedTime; } - public void setLastUpdatedTime(Date lastUpdatedTime) { + public void setLastUpdatedTime(OpaqueInstant lastUpdatedTime) { this.lastUpdatedTime = lastUpdatedTime; } }