Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
Description
First requests to the RampartMessageData in multi-thread execution are failing with error for already locked parameter. This occurs when more than one thread is trying to set CLIENT_SIDE param to the service, the first thread locks the parameter during the addition and the rest cannot override it because it's already locked. I'm providing a patch with test which proves that when threads are more than one a race condition is available during the execution and due to this condition the defect is hard to be reproduced every time. In practise it is failing about 3-4 times for 100 runs (based onto my machine).
monospaced
org.apache.axis2.AxisFault: Error in extracting message properties
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:76)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:335)
at org.apache.axis2.engine.Phase.invoke(Phase.java:308)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:250)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:415)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
at org.apache.axis2.client.ServiceClient.sendRobust(ServiceClient.java:453)
at org.apache.axis2.client.ServiceClient.sendRobust(ServiceClient.java:434)
at org.apache.rampart.RampartTest$1.run(RampartTest.java:347)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.rampart.RampartException: Error in extracting message properties
at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:381)
at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:61)
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:65)
... 13 more
Caused by: org.apache.axis2.AxisFault: The CLIENT_SIDE parameter is already locked and the value cannot be overridden.
at org.apache.axis2.description.AxisDescription.addParameter(AxisDescription.java:104)
at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:197)
... 15 more
org.apache.axis2.AxisFault: Error in extracting message properties
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:76)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:335)
at org.apache.axis2.engine.Phase.invoke(Phase.java:308)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:250)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:415)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
at org.apache.axis2.client.ServiceClient.sendRobust(ServiceClient.java:453)
at org.apache.axis2.client.ServiceClient.sendRobust(ServiceClient.java:434)
at org.apache.rampart.RampartTest$1.run(RampartTest.java:347)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.rampart.RampartException: Error in extracting message properties
at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:381)
at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:61)
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:65)
... 13 more
Caused by: org.apache.axis2.AxisFault: The CLIENT_SIDE parameter is already locked and the value cannot be overridden.
at org.apache.axis2.description.AxisDescription.addParameter(AxisDescription.java:104)
at org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:197)
... 15 more
monospaced
One possible solution is to be used some synchronization mechanism when the parameter is being locked, I'm attaching a patch which uses "synchronized" block by static object (I suppose that an another synchronization mechanism also can be used). I am not sure whether this parameter really should be set per service and if it is not then a synchronization will not be need because the parameter will not be created for every call but this can be answered in the best way by the Rampart developers.
rampart-core
org.apache.rampart.RampartMessageData.java
... if (axisService != null && axisService.getParameter(PARAM_CLIENT_SIDE) != null) { this.isInitiator = true; //<---- After the addition of the parameter the rest of the threads enter here } else { this.isInitiator = !msgCtx.isServerSide(); // TODO if Axis Service is null at this point, do we have to // create a dummy one ?? if (this.isInitiator && axisService != null) { Parameter clientSideParam = new Parameter(); //<---- Two or more threads enter here because the parameter is still not set clientSideParam.setName(PARAM_CLIENT_SIDE); clientSideParam.setLocked(true); //<---- Parameter is being locked msgCtx.getAxisService().addParameter(clientSideParam); //<---- Threads are trying to add the parameter more than once and an exception is generated } } ...