java - Concurrent HTTP Session is returning wrong user -
i experiencing quite weird problem. when 2 users logging @ exact same time, 1 of them detected other.
locale = new locale(getlocale(request).getlanguage(), getlocale(request).getcountry()); strremoteuser = webtools.getuseridwithoutdomainname(request.getremoteuser()).touppercase(); logger.info("[myapp] user " + strremoteuser + " logging in"); logger.info("[myapp] creating session : " + strremoteuser); httpsession session = request.getsession(false); if (session != null) { session.invalidate(); session = request.getsession(); } logger.info("[myapp] user in session : " + strremoteuser);
what following. let's assume 2 users (usr001 , usr002) logging application @ same exact time. located in different location.
logs:
2013-05-14 08:19:38,550 info [com.myapp.action.common.loginaction] [myapp] user usr001 logging in 2013-05-14 08:19:38,551 info [com.myapp.action.common.loginaction] [myapp] creating session : usr001 2013-05-14 08:19:38,760 info [com.myapp.action.common.loginaction] [myapp] user usr002 logging in 2013-05-14 08:19:38,761 info [com.myapp.action.common.loginaction] [myapp] creating session : usr002 2013-05-14 08:19:38,834 info [com.myapp.action.common.loginaction] [myapp] user in session : usr002 2013-05-14 08:19:39,104 info [com.myapp.action.common.loginaction] [myapp] user in session : usr002 2013-05-14 08:19:39,425 info [com.myapp.action.common.loginaction] [myapp] auto added user usr002 2013-05-14 08:19:39,550 info [com.myapp.action.common.loginaction] [myapp] setting user in session: usr002 (673)
as can see, usr002 "wins" concurrent session creation usr001 recognized usr002. if usr001 logs out , log in, works properly.
any thoughts/advice?
thank help.
specs:
- jboss 4.2.3ga
- postgresql 9.0.3
- struts 1.3.5
- ejb3
i glad helped. here's comment posted answer : these classic concurrency issues, if talking same thing. move variable method , run again , @ output.
Comments
Post a Comment