Below code is using incorrect double checked locking pattern. 'volatile' has to
be added for the member variables. See:
http://stackoverflow.com/questions/7855700/why-is-volatile-used-in-this-example-
of-double-checked-locking
Code:
private Map<String, ResourcePreProcessor> preProcessorsMap;
private Map<String, ResourcePostProcessor> postProcessorsMap;
/**
* To be used for internal usage. Ensure that returned object is not null.
*/
private Map<String, ResourcePreProcessor> getPreProcessorsMap() {
if (this.preProcessorsMap == null) {
synchronized (this) {
if (this.preProcessorsMap == null) {
this.preProcessorsMap = newPreProcessorsMap();
}
}
}
return this.preProcessorsMap;
}
/**
* To be used for internal usage. Ensure that returned object is not null.
*/
private Map<String, ResourcePostProcessor> getPostProcessorsMap() {
if (this.postProcessorsMap == null) {
synchronized (this) {
if (this.postProcessorsMap == null) {
this.postProcessorsMap = newPostProcessorsMap();
}
}
}
return this.postProcessorsMap;
}
Original issue reported on code.google.com by dkwak...@gmail.com on 21 Jan 2015 at 9:54
Original issue reported on code.google.com by
dkwak...@gmail.com
on 21 Jan 2015 at 9:54