-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensive global synchronizations #53
Comments
@lightoze this is on purpose, because DOM is not thread-safe, but we promise that our classes are thread-safe. |
Let's look at XLSDocument case first. You create local TransformerFactory and Transformer instances, so you should not worry about them. DOM itself is a potential source of a problem (when the same document is used in concurrent transformations), but in this case synchronization should be on |
The problem is that creating a local instance of |
Do you want to say that it's impossible to run two concurrent XSL transformations inside the same JVM?That's ridiculous. |
Yes, that's exactly what I'm saying and I have a test that proves it. Take a look: https://github.com/jcabi/jcabi-xml/blob/master/src/test/java/com/jcabi/xml/XSLDocumentTest.java#L72-L98 Try to remove synchronization and run |
Just did exactly what you suggested - the test is not failing with removed synchronization. Can you reproduce it yourself now? |
These global synchronizations around resource-intensive code should be avoided:
https://github.com/jcabi/jcabi-xml/blob/master/src/main/java/com/jcabi/xml/XSLDocument.java#L275
https://github.com/jcabi/jcabi-xml/blob/master/src/main/java/com/jcabi/xml/XSDDocument.java#L168
https://github.com/jcabi/jcabi-xml/blob/master/src/main/java/com/jcabi/xml/XSDDocument.java#L184
The text was updated successfully, but these errors were encountered: