I've added this bug to bugzilla:

http://issues.apache.org/bugzilla/show_bug.cgi?id=33836

/Niklas

Niklas Therning wrote:

Hi,

I just upgraded to 2.1.6 and found a bug in JXTemplateGenerator.

The bug appears if one thread calls setup() and removes the cached template from the cache. Before it has been able to reparse the template and put it back into the cache another thread executes generate() and asks the cache for the same template. The second thread will get a null startEvent.

Here's the relevant part of the setup()-method:

synchronized (cache) {
startEvent = (StartDocument)cache.get(uri);
if (startEvent != null) {
int valid = SourceValidity.UNKNOWN;
if (startEvent.compileTime != null) {
valid = startEvent.compileTime.isValid();
}
if (valid == SourceValidity.UNKNOWN && startEvent.compileTime != null) {
SourceValidity validity = inputSource.getValidity();
valid = startEvent.compileTime.isValid(validity);
}
if (valid != SourceValidity.VALID) {
cache.remove(uri);
regenerate = true;
}
} else {
regenerate = true;
}
}
if (regenerate) {
Parser parser = new Parser();
SourceUtil.parse(this.manager, this.inputSource, parser);
startEvent = parser.getStartEvent();
startEvent.compileTime = this.inputSource.getValidity();
synchronized (cache) {
cache.put(uri, startEvent);
}
}


To fix this either put the 'if (regenerate)' block inside the synchronized block or remove the 'cache.remove(uri)' line.

Regards,
Niklas Therning


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to