In my Spring JDBC project I have a class called DBStuff
which i use to connect to DB and make simple DB operations. It's a web project and there are users, so naturally i use session mechanism. When i need to retrieve request data in DBStuff
class, I use this line of code below:
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
But, there is no explanation that if the RequestContextHolder
is thread-safe or not. Even the spring's official forum doesn't have an answer for that. Because of using servlet, I need to provide a thread-safe nature for the users.
By definition RequestContextHolder
is defined as "Holder class to expose the web request in the form of a thread-bound RequestAttributes
object." But I am not sure if "thread-bound" stands for thread-safe.