Hi Sadhana

 

Please see the comments with prefixed with S.B


> Hi Sadhana
> 
> Yes please, some more information/clarification would help.
> 
> Do 192.168.1.102 && localhost identify the same host in your
particular
> case ?
> 
Yes.
>   
> "We send a request to say host http://192.168.1.102:9000
> and then send a ping request to say http://localhost:9000 where both
> requests are going to the same host but different addresses"
> 

Actually, it the same request that is going to different addresses but
the same server.

> I need  some more details please. Does
gwy.ws.jaxrs.ElaborationProcessor
> delegates to gwy.ws.jaxrs.UriInfoManager ? Are these 2 beans share the
> same jaxrs:server endpoint ? Does gwy.ws.jaxrs.ElaborationProcessor
> shows http://192.168.1.102:9000 with UriInfo.getBaseUri() but when it
> delegates to   
> gwy.ws.jaxrs.UriInfoManager it shows localhost ?
> 

I looked at the baseUri value in UriInfo in the very beginning right
after getting the request from CXF. The second thread returns me the
same baseUri value as the first thread. Here is the log sequence:

[DEBUG][11:42:55,531][::][v()][t(http-9000-1)]
[
gwy.ws.jaxrs.ElaborationProcessor.handleRequest(ElaborationProcessor.jav
a:105) ]
---- Http headers: {host=[192.168.1.102:9000], user-agent=[curl/7.16.3
(powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3],
Content-Type=[null], Accept=[*/*]}
[DEBUG][11:42:55,531][::][v()][t(http-9000-2)]
[
gwy.ws.jaxrs.ElaborationProcessor.handleRequest(ElaborationProcessor.jav
a:86) ]
---- In Elaboration Processor
[DEBUG][11:42:55,533][::][v()][t(http-9000-2)]
[
gwy.ws.jaxrs.ElaborationProcessor.handleRequest(ElaborationProcessor.jav
a:105) ]
---- Http headers: {host=[localhost:9000], user-agent=[curl/7.16.3
(powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3],
Content-Type=[null], Accept=[*/*]}
[DEBUG][11:42:55,534][::][v()][t(http-9000-2)]
................(removed messages that are not relevant)
[DEBUG][11:42:55,549][::][v()][t(http-9000-2)]
[
gwy.ws.api.impl.AbstractCrudService.processRead(AbstractCrudService.java
:150) ]
---- ProcessRead UriInfo base URI: http://localhost:9000/domain
[DEBUG][11:42:55,552][::][v()][t(http-9000-1)]
[
gwy.ws.api.impl.AbstractCrudService.processRead(AbstractCrudService.java
:150) ]
---- ProcessRead UriInfo base URI: http://localhost:9000/domain

The ElaborationProcessor is a filter that is showing the http header
values and the host name where the request is being sent.
The AbstractCrudService is the JAX-RS service that is processing the
request URL. The rest of the URL is the same in both cases except the
hostname is different.

The thread 1 request is sent on host 192.168.1.102:9000 but in
AbstractCrusService when I print the getBaseUri from UriInfo object, it
shows localhost:9000 because
Thread-2 request somehow changed the uri value to localhost:9000. 

The UriInfoImpl gets the baseUri like this:
   public URI getBaseUri() {
        URI u = URI.create(HttpUtils.getEndpointAddress(message));
        return HttpUtils.toAbsoluteUri(u, message);
    }

It seems to me that somehow in the message object the baseUri is being
overwritten by thread 2.

I would like to directly print the values from message object. Can u
tell me how to get access to that (using MessageContext)?

I tried:
Message currentMessage =
org.apache.cxf.phase.PhaseInterceptorChain.getCurrentMessage();
      String address =
(String)currentMessage.get(Message.ENDPOINT_ADDRESS);



But it returned me null.



S.B. I think that I can probably can help better if you could create a
very simple web app, including a filter and the actual resource class
and the spring configuration if any.

It is quite hard to figure what is actually happening.   

Looks like HttpUtils.getEndpointAddress(message) is returning null. It
is a different thread from the one that executes in a filter...I'm just
wondering, why is it a different thread after all ? Seeing some sample
code and configuration would help me to see the flow better ... Please
create a trivial web app and attach it to a JIRA...

 

Thanks, Sergey

 


Thanks a lot,
Sadhana
> cheers, Sergey 
> 
> -----Original Message-----
> From: Sadhana Jain [mailto:sadhana.j...@rovicorp.com] 
> Sent: 05 December 2009 01:15
> To: users@cxf.apache.org
> Subject: Race condition when using UriInfo to get baseUri value
> 
> Hi,
> 
> We are using the UriInfo object to getBasrUri() and using UriBuilder
to
> build and create linked URIs for our rest based services.
> 
> However, we are seeing a strange race condition:
> 
> We send a request to say host http://192.168.1.102:9000
> and then send a ping request to say http://localhost:9000 where both
> requests are going to the same host but different addresses, the
> UriInfo object returns the base uri of the second request instead of
the
> first one. So, it seems the UriInfo or message object is somehow
> Being shared between threads.
> 
> Following is the log that shows the problem 9 I have hightlighted the
> hostname and thread numbers.
> 
> [INFO ][17:05:02,258][::][v()][t(http-9000-2)]
> [ 
>
gwy.ws.jaxrs.ElaborationProcessor.handleRequest(ElaborationProcessor.jav
> a:12
> 9) ]
> ---- elaboration map: {host=192.168.1.102:9000,
> gateway-version=1.2.11-2,
> reply=json, user-agent=curl/7.16.3 (powerpc-apple-darwin9.0)
> libcurl/7.16.3
> OpenSSL/0.9.7l zlib/1.2.3, Accept=*/*}
> [INFO ][17:05:02,257][::][v()][t(http-9000-1)]
> [ 
>
gwy.ws.jaxrs.ElaborationProcessor.handleRequest(ElaborationProcessor.jav
> a:12
> 9) ]
> ---- elaboration map: {host=localhost:9000, gateway-version=1.2.11-2,
> reply=json, user-agent=curl/7.16.3 (powerpc-apple-darwin9.0)
> libcurl/7.16.3
> OpenSSL/0.9.7l zlib/1.2.3, Accept=*/*}
> [DEBUG][17:05:02,258][::][v()][t(http-9000-2)]
> [ 
>
gwy.ws.jaxrs.ElaborationProcessor.handleRequest(ElaborationProcessor.jav
> a:14
> 7) ]
> ---- request method: GET
> [DEBUG][17:05:02,258][::][v()][t(http-9000-1)]
> [ 
>
gwy.ws.jaxrs.ElaborationProcessor.handleRequest(ElaborationProcessor.jav
> a:14
> 7) ]
> ---- request method: GET
> [DEBUG][17:05:02,259][::][v()][t(http-9000-2)]
> [ gwy.ws.jaxrs.UriInfoManager.setUi(UriInfoManager.java:51) ]
> ---- setUi() beging UriInfo base URI: http://localhost:9000/domain
> [DEBUG][17:05:02,259][::][v()][t(http-9000-1)]
> [ gwy.ws.jaxrs.UriInfoManager.setUi(UriInfoManager.java:51) ]
> ---- setUi() beging UriInfo base URI: http://localhost:9000/domain
> 
> Any help is much appreciated.
> 
> Please let me know if I can supply more info.
> 
> Thanks,
> Sadhana

Reply via email to