Ben Gollmer wrote: > On May 24, 2007, at 8:12 AM, Niklas Therning wrote: > >> Ben Gollmer wrote: >>> >>> Of course, it probably isn't the best application design to go around >>> blasting IoSession attributes willy-nilly. However, I know my code, >>> and nothing else was storing attributes on IoSessions until I started >>> working with JMX. It would be nice to have a mention of this on the >>> Mina+JMX wiki page for future reference. >>> >> >> There are other stuff in MINA apart from the JMX code which use >> IoSession attributes to store state (e.g. StreamWriteFilter, SSLFilter). >> It's not a good idea to clear all attributes. Instead, why don't you put >> a dedicated Map in the session and store your state in it? Then you >> could just change your code to iterate over the keys of that map and >> remove whatever keys you like. > > True, but I'm not using any filters except my own. I am planning on > moving my attributes to a custom 'namespace', as you suggested. > > I guess I was just caught off guard by the StatCollector using an > attribute. Do the docs for StreamWriteFilter and SSLFilter mention > their use of attributes? > SSLFilter does, StreamWriteFilter doesn't IIRC.
The thing is that the MINA code uses session attributes to store a lot of per session state. It would be a lot of work to document all those places. Just did a search for calls to IoSession.setAttribute() in the MINA source code and got over 30 matches. So it's strongly advised that you don't clear all session attributes, only those that you set yourself. Maybe this should be stated somewhere in the docs (like in the Javadocs for IoSession). If you think so please add a JIRA issue: https://issues.apache.org/jira/browse/DIRMINA -- Niklas Therning www.spamdrain.net
