You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Ashwin Karpe (JIRA)" <ji...@apache.org> on 2010/11/19 23:35:25 UTC

[jira] Updated: (CAMEL-3349) Race condition found in CxfRsEndpoint while getting the endpoint binding under load and performing sync and async invocation

     [ https://issues.apache.org/activemq/browse/CAMEL-3349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ashwin Karpe updated CAMEL-3349:
--------------------------------

    Attachment: camel-cxf-race-condition.patch

Made the getBinding() method synchronized to overcome this issue. The penalty for this is very minimal since, the need for creating a binding is only on the first set of invocations. The binding is then held until the endpoint is in operation.


> Race condition found in CxfRsEndpoint while getting the endpoint binding under load and performing sync and async invocation
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3349
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3349
>             Project: Apache Camel
>          Issue Type: Bug
>            Reporter: Ashwin Karpe
>            Assignee: Ashwin Karpe
>         Attachments: camel-cxf-race-condition.patch
>
>
> The CxfRsEndpoint's getBinding method is not thread safe. At a customer site, I ran into an issue at startup if 2 threads raced to perform sync and async invocation, the code for getBinding (given below) would react in the following way.
>       - Thread 1 would proceed to create a binding object 
>       - Thread 2 would mean while still find the  binding to be null and proceed to create a new binding
>       - Meanwhile thread one would have its binding and set the Atomic boolean for binding initialized and proceed to set the HeaderStrategy.
>       - Thread 2 meanwhile would overwrite the original binding object and find that Atomic boolean already set and would have no way to associate a HeaderFilterStrategy object since the flag is up.
>       - In the absence of a HeaderFilterStrategy, copying of ProtocolHeaders etc will throw exceptions on every following request/invocation.
> --------------------------------------------------
>     public CxfRsBinding getBinding() {
>         if (binding == null) {
>             binding = new DefaultCxfRsBinding();
>             if (LOG.isDebugEnabled()) {
>                 LOG.debug("Create default CXF Binding " + binding);
>             }
>         } 
>         
>         if (!bindingInitialized.getAndSet(true) && binding instanceof HeaderFilterStrategyAware) {
>             ((HeaderFilterStrategyAware)binding).setHeaderFilterStrategy(getHeaderFilterStrategy());
>         }
>         
>         return binding;
>     }
> ------------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.