Skip to content
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

Open
lightoze opened this issue Feb 12, 2015 · 6 comments
Open

Extensive global synchronizations #53

lightoze opened this issue Feb 12, 2015 · 6 comments

Comments

@yegor256
Copy link
Member

@lightoze this is on purpose, because DOM is not thread-safe, but we promise that our classes are thread-safe.

@lightoze
Copy link
Author

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 xml, xml.node() or whatever.

@yegor256
Copy link
Member

The problem is that creating a local instance of Transformer doesn't make it thread safe :( I believe it's full of static properties inside.

@lightoze
Copy link
Author

Do you want to say that it's impossible to run two concurrent XSL transformations inside the same JVM?That's ridiculous.
Transformer documentation says clearly: An object of this class may not be used in multiple threads running concurrently. Different Transformers may be used concurrently by different threads.

@yegor256
Copy link
Member

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 mvn clean test and you will see what happens.

@lightoze
Copy link
Author

Just did exactly what you suggested - the test is not failing with removed synchronization. Can you reproduce it yourself now?
Tested with JRE 1.8.0_31 and 1.7.0_76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants