I am trying to use RequestContextHolder
, in this class we have two methods currentRequestAttributes()
and getRequestAttributes()
what is the difference between these methods ?
I saw these two methods have the same meaning, then why we have two methods ?
My requirement is I want to set one attribute in the currently processing request in one class of my application, and use it in another class of the same application for the same request processing ,so I thought of using the RequestContextHolder
, but I found those two methods with the same meaning which one is more meaningful for my problem ?
Note: Reason why am using this class is I do not want to pass the flag calculated in the class, all the way to the starting class of the spring boot app , because if I want to pass , then I need to change the all method signatures in that call stack , so many method signatures I might need change, and in that this flag is calculated per request , I decided to go with that class RequestContextHolder
.
currentRequestAttributes()
is justgetRequestAttributes()
+if ( getRequestAttributes() == null)
fallback toFacesRequestAttributesFactory.getFacesRequestAttributes();
+ if null throw exception github.com/spring-projects/spring-framework/blob/master/…