While testing concurrent access in our web application we are having some difficulty tracing session behavior.
Say we have three different users, A, B, and C.
We are logging in to the application with three different browsers with these three users then at run time my user object is changing from B to A or B to C or C to A, but this is happening randomly.
My UserContextHolder class is :
public final class UserObjContextHolder {
private static final ThreadLocal<UserObj> CONTEXT_HOLDER = new ThreadLocal<UserObj>();
private UserObjContextHolder() {
}
public static void setUserObj(UserObj userObj) {
CONTEXT_HOLDER.set(userObj);
}
public static UserObj getUserObj() {
return CONTEXT_HOLDER.get();
}
}
I am using Hibernate for ORM and Spring MVC
Can anybody tell me reasons for this session behavior or how I can synchronize it?
I noticed one thing: if User A is logged in and doing some search operation and if User B logs in at the same time then userObj A is changing to userObj B.
Is it related to Application server setting? This happens only while doing authentication.