diff --git a/ph-schematron-pure/src/main/java/com/helger/schematron/pure/xpath/XPathLetVariableResolver.java b/ph-schematron-pure/src/main/java/com/helger/schematron/pure/xpath/XPathLetVariableResolver.java index 91fa32111..df0a36aad 100644 --- a/ph-schematron-pure/src/main/java/com/helger/schematron/pure/xpath/XPathLetVariableResolver.java +++ b/ph-schematron-pure/src/main/java/com/helger/schematron/pure/xpath/XPathLetVariableResolver.java @@ -30,7 +30,14 @@ @NotThreadSafe public class XPathLetVariableResolver implements XPathVariableResolver { - private final ICommonsMap m_aVariables = new CommonsHashMap <> (); + private final ThreadLocal> m_aVariables = new ThreadLocal<> () { + @Override + protected ICommonsMap initialValue() + { + return new CommonsHashMap <> (); + } + }; + private final XPathVariableResolver m_aDelegatedResolver; public XPathLetVariableResolver (@Nullable final XPathVariableResolver aResolver) @@ -41,7 +48,7 @@ public XPathLetVariableResolver (@Nullable final XPathVariableResolver aResolver public void setVariableValue (@Nonnull final QName aVariableName, @Nullable final Object aValue) { ValueEnforcer.notNull (aVariableName, "VariableName"); - m_aVariables.put (aVariableName, aValue); + m_aVariables.get().put (aVariableName, aValue); } /** @@ -53,7 +60,7 @@ public void setVariableValue (@Nonnull final QName aVariableName, @Nullable fina public void removeVariable (@Nullable final QName aVariableName) { if (aVariableName != null) - m_aVariables.remove (aVariableName); + m_aVariables.get().remove (aVariableName); } @Override @@ -62,7 +69,7 @@ public Object resolveVariable (@Nullable final QName aVariableName) if (aVariableName != null) { // 1. variables - final Object result = m_aVariables.get (aVariableName); + final Object result = m_aVariables.get().get (aVariableName); if (result != null) return result;