XFire

XFire Client not ThreadSafe

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2.4
  • Fix Version/s: 1.2.5
  • Component/s: Core
  • Labels:
    None
  • Environment:
    Linux 2.6, Java 1.4.2 / Java 1.5
  • Number of attachments :
    2

Description

I use XFire as a client. witin Mule,

The XFire Client are in a Pool (common pool) and
many threads are using thoses clients to call a service.

Sometimes (about 14 times / 60) with 2 threads this happens :

DEBUG 2007-02-22 12:57:16,520 [Test-1] org.codehaus.xfire.client.Client:
Received message to http://serveur:3003/scoperta/scopertaTest
DEBUG 2007-02-22 12:57:16,520 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: adding handler
org.codehaus.xfire.client.CorrelatorHandler@c67a88 to phase pre-dispatch
DEBUG 2007-02-22 12:57:16,520 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: adding handler
org.codehaus.xfire.soap.handler.ReadHeadersHandler@1397e5c to phase parse
DEBUG 2007-02-22 12:57:16,520 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: adding handler
org.codehaus.xfire.soap.handler.ValidateHeadersHandler@196e136 to phase
pre-invoke
DEBUG 2007-02-22 12:57:16,521 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: adding handler
org.codehaus.xfire.handler.LocateBindingHandler@9bad5a to phase dispatch
DEBUG 2007-02-22 12:57:16,521 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: adding handler
org.codehaus.xfire.soap.handler.SoapActionInHandler@91f005 to phase dispatch
DEBUG 2007-02-22 12:57:16,521 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: adding handler
org.codehaus.xfire.soap.handler.SoapBodyHandler@1250ff2 to phase dispatch
DEBUG 2007-02-22 12:57:16,521 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: Invoking phase transport
DEBUG 2007-02-22 12:57:16,521 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: Invoking phase parse
DEBUG 2007-02-22 12:57:16,521 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: Invoking handler
org.codehaus.xfire.soap.handler.ReadHeadersHandler in phase parse
DEBUG 2007-02-22 12:57:16,521 [Test-1]

org.codehaus.xfire.handler.HandlerPipeline: Invoking phase pre-dispatch
DEBUG 2007-02-22 12:57:16,521 [Test-1]
org.codehaus.xfire.handler.HandlerPipeline: Invoking handler
org.codehaus.xfire.client.CorrelatorHandler in phase pre-dispatch
DEBUG 2007-02-22 12:57:16,521 [Test-1] org.codehaus.xfire.client.Client:
Correlating context with ID 1172167036476261041791506
INFO 2007-02-22 12:57:16,521 [Test-1] org.codehaus.xfire.client.Client:
No correlated invocation was found.

Cause:

When a client is triggered : Client.onReceive(MessageContext)

It creates a pipeline,
put the handlers in the pipeline then invoke the pipeline *using
MessageContext*

HOWEVER sometimes the client triggered != the client in the context.
so the handlers added to the pipeline are not related to the good client.

Fix:
See patch in attachment

The fix does :
Get the handlers for the client in the MessageContext.
Add them to the pipeline. (not the ones from "this")

  1. Client.java.patch
    23/Feb/07 8:30 AM
    1 kB
    Tony Bussieres
  2. LocalClientTest.patch
    23/Feb/07 9:26 AM
    3 kB
    Tony Bussieres

Activity

Hide
Dan Diephouse added a comment -

Thanks Tony! Scheduling for 1.2.5.

Show
Dan Diephouse added a comment - Thanks Tony! Scheduling for 1.2.5.
Hide
Tony Bussieres added a comment -

This is a proof that there is a multithreading problem in the Client.

The test starts 3 Thread that contain a Client
and does the same invoke as described in testInvoke()
Each Thread invoke 15 times the service.

If the Client patch is not applied I get the :

Feb 23, 2007 10:25:22 AM org.codehaus.xfire.client.CorrelatorHandler invoke
INFO: No correlated invocation was found.

If the patch is applied, everything goes OK

Show
Tony Bussieres added a comment - This is a proof that there is a multithreading problem in the Client. The test starts 3 Thread that contain a Client and does the same invoke as described in testInvoke() Each Thread invoke 15 times the service. If the Client patch is not applied I get the : Feb 23, 2007 10:25:22 AM org.codehaus.xfire.client.CorrelatorHandler invoke INFO: No correlated invocation was found. If the patch is applied, everything goes OK
Hide
Tomasz Sztelak added a comment -

Fixed in svn

Show
Tomasz Sztelak added a comment - Fixed in svn
Hide
Tony Bussieres added a comment -

Maybe the LoadClientTest patch should be applied as well ?

Show
Tony Bussieres added a comment - Maybe the LoadClientTest patch should be applied as well ?
Hide
Tomasz Sztelak added a comment -

But a little later Probably i'll create separate junit.

Show
Tomasz Sztelak added a comment - But a little later Probably i'll create separate junit.
Hide
Holger Hoffstätte added a comment -

Tomasz, can you please comment on whether the patch actually does fix the problem with correlation when several clients are used? There is still the possibility that the bug might have been caused by Mule which used client pooling. Will correlation generally work when multiple client objects are talking to the same endpoint from different threads? If that is not the case we could also try to use the same client for every endpoint.

Show
Holger Hoffstätte added a comment - Tomasz, can you please comment on whether the patch actually does fix the problem with correlation when several clients are used? There is still the possibility that the bug might have been caused by Mule which used client pooling. Will correlation generally work when multiple client objects are talking to the same endpoint from different threads? If that is not the case we could also try to use the same client for every endpoint.
Hide
Tony Bussieres added a comment -

Holger,

The TestCase I've attached shows the same problem without using Mule. I believe that the problem was on the Xfire side.

It's good to double check anyway

-Tony

Show
Tony Bussieres added a comment - Holger, The TestCase I've attached shows the same problem without using Mule. I believe that the problem was on the Xfire side. It's good to double check anyway -Tony

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: