tkobayas commented on code in PR #6871:
URL: https://github.com/apache/incubator-kie/pull/6871#discussion_r3725375462


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/XQueryImplUtil.java:
##########
@@ -26,11 +26,27 @@
 import net.sf.saxon.s9api.XQueryExecutable;
 import net.sf.saxon.s9api.SaxonApiException;
 
-import java.util.regex.Pattern;
-
 public class XQueryImplUtil {
 
-    private static final Pattern XML_CHARACTER_REFERENCES_PATTERN = 
Pattern.compile("['\"&<>]");
+    /**
+     * Single Saxon Processor instance shared across all calls. A {@code 
Processor} is thread-safe
+     * and expensive to construct: it initialises the Saxon {@code 
Configuration} and owns shared
+     * resources such as the Saxon NamePool. Saxon recommends creating it once 
and reusing it;
+     * nothing can be shared between separate {@code Processor} instances.
+     * Note: {@code new Processor(false)} does not perform a license check — 
it unconditionally
+     * creates a plain Home Edition configuration.
+     */
+    private static final Processor PROCESSOR = new Processor(false);
+
+    /**
+     * Single XQueryCompiler instance. XQueryCompiler is reusable and may in 
principle
+     * be used concurrently in multiple threads. In practice, concurrent 
compilations share
+     * the same ErrorReporter, making it difficult to associate error messages 
with specific
+     * compilations. Since errors here are immediately wrapped and re-thrown as
+     * {@link IllegalArgumentException}, this is not a concern.

Review Comment:
   I think the error message could still be replaced by another thread in a 
concurrent scenario, even if it's wrapped in an `IllegalArgumentException`. So 
I think "`this is not a concern`" is too strong a statement.
   
   We may instead acknowledge that we're using a shared instance for 
performance, with the trade-off that error messages may not always be 
attributed correctly.
   



-- 
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]

Reply via email to