Project

Profile

Help

Saxon libraries thread safe?

Added by Anonymous over 18 years ago

Legacy ID: #3721314 Legacy Poster: Morgan C (infinsq)

Using saxon in multiple threads but with separate stylesheets can occasionally result in the following exception: <pre> java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[Default : 5,5,main] at java.util.HashMap.onEntry(HashMap.java(Inlined Compiled Code)) at java.util.HashMap.transfer(HashMap.java(Compiled Code)) at java.util.HashMap.resize(HashMap.java(Inlined Compiled Code)) at java.util.HashMap.addEntry(HashMap.java(Compiled Code)) at java.util.HashMap.put(HashMap.java(Compiled Code)) at net.sf.saxon.type.TypeHierarchy.relationship(TypeHierarchy.java:88) at net.sf.saxon.expr.TypeChecker.staticTypeCheck(TypeChecker.java:106) at net.sf.saxon.expr.GeneralComparison.typeCheck(GeneralComparison.java:80) at net.sf.saxon.expr.FilterExpression.typeCheck(FilterExpression.java:156) at net.sf.saxon.expr.PathExpression.typeCheck(PathExpression.java:295) at net.sf.saxon.style.StyleElement.typeCheck(StyleElement.java:974) at net.sf.saxon.style.XSLGeneralVariable.validate(XSLGeneralVariable.java:269) at net.sf.saxon.style.XSLVariableDeclaration.validate(XSLVariableDeclaration.java:127) at net.sf.saxon.style.StyleElement.validateSubtree(StyleElement.java:1166) at net.sf.saxon.style.StyleElement.validateChildren(StyleElement.java:1199) at net.sf.saxon.style.StyleElement.validateSubtree(StyleElement.java:1175) at net.sf.saxon.style.XSLStylesheet.preprocess(XSLStylesheet.java:643) at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:279) at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:117) at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:130) </pre> Any thoughts on what I might be doing wrong, or how to fix this?


Replies (6)

Please register to reply

RE: Saxon libraries thread safe? - Added by Anonymous over 18 years ago

Legacy ID: #3721499 Legacy Poster: Michael Kay (mhkay)

You've found a bug here - thanks for reporting it. The cache used for type information is shared between threads and should therefore be synchronized. I'll produce a patch in the next couple of days.

RE: Saxon libraries thread safe? - Added by Anonymous over 18 years ago

Legacy ID: #3724301 Legacy Poster: Michael Kay (mhkay)

I've entered this in the bug register at https://sourceforge.net/tracker/index.php?func=detail&amp;aid=1486588&amp;group_id=29872&amp;atid=397617 with a description of a patch. If you can give any feedback on the performance effects of the patch in a multithreaded environment, I would be grateful. A faster solution is available but depends on J2SE 5.0.

RE: Saxon libraries thread safe? - Added by Anonymous over 18 years ago

Legacy ID: #3724333 Legacy Poster: Morgan C (infinsq)

Appreciate the turn around on the patch. I definitely need 1.4 support so using ConcurrentHashMap without bundling it in would not be acceptable. I know that ConcurrentHashMap is much faster than Hashtable, but is a synchronizedMap faster as well? AFAIK, the only difference is a synchronizedMap can take a null value. If you don't need to store nulls, using Hashtable may improve code readability. Just a thought.

RE: Saxon libraries thread safe? - Added by Anonymous over 18 years ago

Legacy ID: #3724420 Legacy Poster: Michael Kay (mhkay)

I did a bit of scouting about and the recommendation seemed to be to use SynchronizedMap rather than HashTable, but I suspect there's not much in it.

RE: Saxon libraries thread safe? - Added by Anonymous over 18 years ago

Legacy ID: #3724492 Legacy Poster: Morgan C (infinsq)

I'm fairly ignorant of the saxon release cycle. When do you expect this to be in a release?

RE: Saxon libraries thread safe? - Added by Anonymous over 18 years ago

Legacy ID: #3724515 Legacy Poster: Michael Kay (mhkay)

The usual pattern is a functionality release every three to four months, with a point release inbetween. We're probably a couple of months away from the next release.

    (1-6/6)

    Please register to reply