• Post Reply Bookmark Topic Watch Topic
  • New Topic

Warning. Sybex book. p.285. Fundamentals error.  RSS feed

Mikalai Zaikin
Ranch Hand
Posts: 3418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Ranchers.
Another fundamentals error from book's authors:
The session is retrieved dynamically from the current request object.
Because of Java’s design, you are guaranteed that the request parameter is
directly threaded to the current client. As a result, the session returned is also
the session associated with the client accessing this code. Any attributes
added or acquired fall under the same category and are thread-safe. Once the
variable is local to a method, there is no threat of data corruption from intercepting
threads due to local variable threading rules. Figure 8.8 provides a
visual representation of how session objects and their attributes are linked
directly to the client thread.
Fundamentally, each client operates on its own session object. By design,
adding session attributes is thread-safe.
It seems to me that authors does not know that one client can open several browser windows, participating in the same HTTP session and thus session attributes can be accessed concurretly by several threads (via several brousers) simultaneously.
So, by design,
adding session attributes is NOT thread-safe.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!