You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by ch...@apache.org on 2007/04/29 08:38:59 UTC
svn commit: r533471 -
/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java
Author: chathura_ce
Date: Sat Apr 28 23:38:58 2007
New Revision: 533471
URL: http://svn.apache.org/viewvc?view=rev&rev=533471
Log:
Fixed a concurrent issue in the callbackStore's iterator access.
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java?view=diff&rev=533471&r1=533470&r2=533471
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java Sat Apr 28 23:38:58 2007
@@ -74,40 +74,46 @@
// checks if callback store contains at least one entry before proceeding. otherwise getting
// the time for doing nothing would be a inefficient task.
- if (callbackStore.size() > 0) {
- long currentTime = currentTime();
+ // we have to synchronize this on the callbackStore as iterators of thread safe collections
+ // are not thread safe. callbackStore can be modified concurrently by the SynapseCallbackReceiver.
+ synchronized(callbackStore) {
- Iterator i = callbackStore.keySet().iterator();
+ if (callbackStore.size() > 0) {
- while (i.hasNext()) {
- Object key = i.next();
- AsyncCallback callback = (AsyncCallback) callbackStore.get(key);
+ long currentTime = currentTime();
- if (callback.getTimeOutAction() != Constants.NONE) {
+ Iterator i = callbackStore.keySet().iterator();
- if (callback.getTimeOutOn() <= currentTime) {
- callbackStore.remove(key);
+ while (i.hasNext()) {
+ Object key = i.next();
+ AsyncCallback callback = (AsyncCallback) callbackStore.get(key);
- if (callback.getTimeOutAction() == Constants.DISCARD_AND_FAULT) {
+ if (callback.getTimeOutAction() != Constants.NONE) {
- // actiavte the fault sequence of the current sequence mediator
+ if (callback.getTimeOutOn() <= currentTime) {
+ callbackStore.remove(key);
- MessageContext msgContext = callback.getSynapseOutMsgCtx();
+ if (callback.getTimeOutAction() == Constants.DISCARD_AND_FAULT) {
- // add an error code to the message context, so that error sequences
- // can identify the cause of error
- msgContext.setProperty(Constants.ERROR_CODE, Constants.TIME_OUT);
+ // actiavte the fault sequence of the current sequence mediator
- Stack faultStack = msgContext.getFaultStack();
+ MessageContext msgContext = callback.getSynapseOutMsgCtx();
- for (int j = 0; j < faultStack.size(); j++) {
- Object o = faultStack.pop();
- if (o instanceof MediatorFaultHandler) {
- ((MediatorFaultHandler) o).handleFault(msgContext);
+ // add an error code to the message context, so that error sequences
+ // can identify the cause of error
+ msgContext.setProperty(Constants.ERROR_CODE, Constants.TIME_OUT);
+
+ Stack faultStack = msgContext.getFaultStack();
+
+ for (int j = 0; j < faultStack.size(); j++) {
+ Object o = faultStack.pop();
+ if (o instanceof MediatorFaultHandler) {
+ ((MediatorFaultHandler) o).handleFault(msgContext);
+ }
}
- }
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org