I have some java code that gets and sets a session attribute:
Object obj = session.getAttribute(TEST_ATTR);
if (obj==null) {
obj = new MyObject();
sessio
Your code won't work for at least two reasons.
1) If the session doesn't exist, then you could easily create it twice for the same user, and have an ugly race condition.
2) If the session is not the same object across threads, then it won't work anyway. The session will probably be equals() to the same session in another thread, but that won't work.