pavelsalamon commented on code in PR #59:
URL: https://github.com/apache/ws-xmlschema/pull/59#discussion_r1759089604
##########
xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java:
##########
@@ -72,6 +74,11 @@ public XmlSchemaSerializerException(String msg) {
public static final String XSD_NAMESPACE =
XMLConstants.W3C_XML_SCHEMA_NS_URI;
private static final String XMLNS_NAMESPACE_URI =
"http://www.w3.org/2000/xmlns/";
+ /**
+ * Keeps track of already serialized schemas.
+ */
+ private static ThreadLocal<Set<XmlSchema>> serializedSchemaElements = new
ThreadLocal<>();
Review Comment:
I believe so.
When imports are used, new instances of `XmlSchemaSerializer` are created
for them so we need to share the same `Set<XmlSchema>` between multiple
instances of serializer. That's why `static` is used.
But we don't want to share the same `Set<XmlSchema>` globally between all
threads that are potentially serializing something in the same JVM. That leads
to `ThreadLocal`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]