Is nl.adaptivity.xmlutil.serialization.XML
threadsafe?
#245
-
After updating to 0.90.2, I'm getting an intermittent exception when running unit tests that serialize XML:
It's not always in the same test and it doesn't seem to happen when running individual tests. I think this test framework runs multiple tests in parallel and they're using a single shared instance of |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The short answer is no, Alternatively I've implemented the default implementation on dev to use threadlocals for Java/native (not js/wasm). However as some of the types are not public you cannot work around it except by disabling the caching. |
Beta Was this translation helpful? Give feedback.
-
This should be resolved/fixed with the 0.90.3 release that should be threadSafe by default. Let me know if it works/breaks. You can of course either wrap the format in a threadlocal, not use caching, or not store the format at all. |
Beta Was this translation helpful? Give feedback.
The short answer is no,
XML
objects are not threadsafe (if you enable caching). I'll document it. Using different instances in different threads should be fine (but sharing the cache across invocations would improve speed).Alternatively I've implemented the default implementation on dev to use threadlocals for Java/native (not js/wasm). However as some of the types are not public you cannot work around it except by disabling the caching.