problems with thread locals?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

problems with thread locals?

jbrisbin
Not sure what's going on here, but I have an HTTP server set up using Grizzly's HTTP server abstractions (I'm subclassing HttpHandler). While servicing a request, I'm trying to make an asynchronous REST connection to another service using the HttpClientFilter and a raw TCPNIOTransport, which I configure on demand.

But weird things happen if I have a ByteBufferMemoryManager in my server transport. I get odd ClassCastExceptions when I try and do a "new HttpClientFilter()" while servicing the request that lead me to believe there's some ThreadLocal magic going on that is making this difficult.

Can I create an outbound HTTP connection in Grizzly while servicing an incoming HTTP request from the client using two different transports/filter chains?


Thanks!

Jon Brisbin
http//jbrisbin.com

Reply | Threaded
Open this post in threaded view
|

Re: problems with thread locals?

oleksiys
Administrator
Hi Jon,

Not sure what's going on here, but I have an HTTP server set up using Grizzly's HTTP server abstractions (I'm subclassing HttpHandler). While servicing a request, I'm trying to make an asynchronous REST connection to another service using the HttpClientFilter and a raw TCPNIOTransport, which I configure on demand.

But weird things happen if I have a ByteBufferMemoryManager in my server transport. I get odd ClassCastExceptions when I try and do a "new HttpClientFilter()" while servicing the request that lead me to believe there's some ThreadLocal magic going on that is making this difficult.

Can I create an outbound HTTP connection in Grizzly while servicing an incoming HTTP request from the client using two different transports/filter chains?
Absolutely.

As usual some testcase would help ;)

Thanks.

WBR,
Alexey.

Reply | Threaded
Open this post in threaded view
|

Re: problems with thread locals?

jbrisbin
I think I figured it out. My debugging led me to believe something that wasn't the case. :) I found the problem with the way I was creating the transport...

Sorry for the noise.

Thanks!

Jon Brisbin
http//jbrisbin.com


From: "Oleksiy Stashok" <[hidden email]>
To: [hidden email]
Sent: Wednesday, August 17, 2011 4:34:10 AM
Subject: Re: problems with thread locals?

Hi Jon,

Not sure what's going on here, but I have an HTTP server set up using Grizzly's HTTP server abstractions (I'm subclassing HttpHandler). While servicing a request, I'm trying to make an asynchronous REST connection to another service using the HttpClientFilter and a raw TCPNIOTransport, which I configure on demand.

But weird things happen if I have a ByteBufferMemoryManager in my server transport. I get odd ClassCastExceptions when I try and do a "new HttpClientFilter()" while servicing the request that lead me to believe there's some ThreadLocal magic going on that is making this difficult.

Can I create an outbound HTTP connection in Grizzly while servicing an incoming HTTP request from the client using two different transports/filter chains?
Absolutely.

As usual some testcase would help ;)

Thanks.

WBR,
Alexey.