Re: sharing sessionstata between encoder and decoder
Hi, jan de vries wrote: Hello, I have a class which stores session specific data with session.setAttribute(SessionState.STATE_KEY, ss); But this contains data like (CharsetEncoder) which usage should not be interleaved by doDecode and encode. H. Don't you use a CharsetEncoder for sent message and CharsetDecoder for received message ? I don't think it's necessary at all to lock something, as encoding and decoding aren't sharing anything ... -- -- cordialement, regards, Emmanuel Lécharny www.iktek.com directory.apache.org
Re: sharing sessionstata between encoder and decoder
One strategy would be to synchronize the 'session' instance itself. jan de vries wrote: Well, it was just an example to make my point clear. My SessionState contaans a lot more then that. For the decoder you are right, but the encoder CharsetEncoder can give problems since Session.write might be called simultaneously if i understand the documentation correctly. But actually its not about the encoder or decoder, but about the other things in my SessionState class ;). ... But please note that performing more than one write(Object) calls at the same time will cause the [..] is executed simnutaneously, and therefore you have to make sure the IoFilter implementations you're using are thread-safe, too. (mmm i believe that should be simultaneously in the documentation) Emmanuel Lecharny wrote: Hi, jan de vries wrote: Hello, I have a class which stores session specific data with session.setAttribute(SessionState.STATE_KEY, ss); But this contains data like (CharsetEncoder) which usage should not be interleaved by doDecode and encode. H. Don't you use a CharsetEncoder for sent message and CharsetDecoder for received message ? I don't think it's necessary at all to lock something, as encoding and decoding aren't sharing anything ... -- -- cordialement, regards, Emmanuel Lécharny www.iktek.com directory.apache.org
Re: sharing sessionstata between encoder and decoder
jan de vries wrote: Well, it was just an example to make my point clear. My SessionState contaans a lot more then that. For the decoder you are right, but the encoder CharsetEncoder can give problems since Session.write might be called simultaneously if i understand the documentation correctly. But actually its not about the encoder or decoder, but about the other things in my SessionState class ;). ... But please note that performing more than one write(Object) calls at the same time will cause the [..] is executed simnutaneously, and therefore you have to make sure the IoFilter implementations you're using are thread-safe, too. If you are using an OrderedThreadPoolExecutor, then you have the guarantee that there will be no problem with the event processing : http://mina.apache.org/report/trunk/apidocs/org/apache/mina/filter/executor/ExecutorFilter.html http://mina.apache.org/report/trunk/apidocs/org/apache/mina/filter/executor/OrderedThreadPoolExecutor.html -- -- cordialement, regards, Emmanuel Lécharny www.iktek.com directory.apache.org