Update of /cvsroot/exist/eXist-1.0/src/org/exist/cocoon
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5368/src/org/exist/cocoon
Modified Files:
XQueryGenerator.java
Log Message:
Fixed some synchronization issues in the XQuery engine:
* Compiled XQuery expressions are no longer shared between
different threads. The XQuery cache in XQueryServlet and
XQueryGenerator is declared as thread local now.
* The XQueryContext of a compiled XQuery now gets the correct
database broker object set.
Index: XQueryGenerator.java
===================================================================
RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/cocoon/XQueryGenerator.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** XQueryGenerator.java 23 Feb 2004 09:36:11 -0000 1.10
--- XQueryGenerator.java 5 Mar 2004 11:15:28 -0000 1.11
***************
*** 86,90 ****
private String defaultPassword = null;
private Map optionalParameters;
! private Map cache = new HashMap();
private class CachedExpression {
--- 86,100 ----
private String defaultPassword = null;
private Map optionalParameters;
!
! private ThreadLocal cache = new ThreadLocal() {
!
! /* (non-Javadoc)
! * @see java.lang.ThreadLocal#initialValue()
! */
! protected Object initialValue() {
! return new HashMap();
! }
! };
!
private class CachedExpression {
***************
*** 207,212 ****
CompiledExpression expr;
CachedExpression cached;
! synchronized (cache) {
! cached = (CachedExpression) cache.get(uri);
if (cached != null) {
// check if source is valid or should be reloaded
--- 217,221 ----
CompiledExpression expr;
CachedExpression cached;
! cached = (CachedExpression) ((Map)cache.get()).get(uri);
if (cached != null) {
// check if source is valid or should be reloaded
***************
*** 216,220 ****
.getValidity());
if (valid != SourceValidity.VALID) {
! cache.remove(uri);
cached = null;
}
--- 225,229 ----
.getValidity());
if (valid != SourceValidity.VALID) {
! ((Map)cache.get()).remove(uri);
cached = null;
}
***************
*** 225,232 ****
cached = new CachedExpression(inputSource.getValidity(),
expr);
! cache.put(uri, cached);
! } else
expr = cached.expr;
! }
ResourceSet result = service.execute(expr);
XMLResource resource;
--- 234,241 ----
cached = new CachedExpression(inputSource.getValidity(),
expr);
! ((Map)cache.get()).put(uri, cached);
! } else {
expr = cached.expr;
! }
ResourceSet result = service.execute(expr);
XMLResource resource;
|