Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: Release 1.5.6
-
Fix Version/s: Release 1.5.7
-
Component/s: None
-
Labels:None
-
Environment:Tomcat 5.5, Java 1.6, Stripes 1.5.6
Description
Our web.xml does NOT have StripesFilter, but it does have DynamicMappingFilter (DMF) with configuration for StripesFilter.
When DMF finds that there is no StripesFilter in servlet context, it tries to create its own:
// Get a reference to a StripesFilter instance
StripesFilter sf = getStripesFilter();
if (sf == null) {
initStripesFilter((HttpServletRequest) request, wrapper);
sf = getStripesFilter();
}
Problem may occur when multiple threads execute this code at once. They all find that getStripesFilter() returns null, and go ahead to initStripesFilter(). This method is synchronized, but it doesn't check if filter wasn't already created by other thread. So it happily creates new StripesFilter, possibly for second or third time
This later causes problem in StripesFilter.getConfiguration() method when called outside of stripes-action. Stripes.getConfiguration() if there is only single configuration, and if it finds multiple configs, it throws exception ![]()