From 7af576d39f65de859511095f045ae5dd2d64bba5 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Tue, 8 Aug 2023 15:21:55 +0100 Subject: [PATCH 1/6] Forward patch from 5.5.2. [#542] Add type parameter for abs() --- .gitignore | 3 +++ .../formatter/GoogleJavaFormatter.java | 12 ------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 6b36d500a..16c89011e 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ buildNumber.properties # Binary files *.class +/dmn-tck-it/dmn-tck-it-python-translator/.venv/ +/dmn-tck-it/dmn-tck-it-python-translator/src/scripts.egg-info/ +/dmn-tck-it/dmn-tck-it-python-translator/src/UNKNOWN.egg-info/ diff --git a/dmn-core/src/main/java/com/gs/dmn/transformation/formatter/GoogleJavaFormatter.java b/dmn-core/src/main/java/com/gs/dmn/transformation/formatter/GoogleJavaFormatter.java index 3e5a38b21..1e1490ed7 100644 --- a/dmn-core/src/main/java/com/gs/dmn/transformation/formatter/GoogleJavaFormatter.java +++ b/dmn-core/src/main/java/com/gs/dmn/transformation/formatter/GoogleJavaFormatter.java @@ -25,7 +25,6 @@ public class GoogleJavaFormatter implements JavaFormatter { static { try { - setFinalStatic(); JavaFormatterOptions options = JavaFormatterOptions.builder().style(JavaFormatterOptions.Style.GOOGLE).build(); FORMATTER = new Formatter(options); } catch (Exception e) { @@ -33,17 +32,6 @@ public class GoogleJavaFormatter implements JavaFormatter { } } - static void setFinalStatic() throws Exception { - Field field = JavaFormatterOptions.class.getDeclaredField("DEFAULT_MAX_LINE_LENGTH"); - field.setAccessible(true); - - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - - field.set(null, 150); - } - @Override public String formatSource(String code) { try { From 843c14a024afdc22971be5e78701319ab4a9baef Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Tue, 8 Aug 2023 15:23:02 +0100 Subject: [PATCH 2/6] Forward patch from 5.5.2. [#585] Add function 'string join' to 5.5.3 --- .../StandardEnvironmentFactory.java | 1 + .../synthesis/AbstractFEELToJavaVisitor.java | 1 + .../src/main/resources/dmn/1.3/FEELLexer.g4 | 3 +++ .../AbstractStandardFEELProcessorTest.java | 12 ++++++++++ .../feel/analysis/syntax/FEELLexerTest.java | 3 +++ .../gs/dmn/feel/lib/BaseStandardFEELLib.java | 22 +++++++++++++++++++ .../com/gs/dmn/feel/lib/StandardFEELLib.java | 4 ++++ .../lib/type/string/DefaultStringLib.java | 19 ++++++++++++++++ .../dmn/feel/lib/type/string/StringLib.java | 4 ++++ .../BaseStandardFEELLibExceptionsTest.java | 6 +++++ .../dmn/feel/lib/BaseStandardFEELLibTest.java | 21 ++++++++++++++++-- .../gs/dmn/feel/lib/FEELOperatorsTest.java | 8 +++++++ .../gs/dmn/feel/lib/stub/StringLibStub.java | 10 +++++++++ 13 files changed, 112 insertions(+), 2 deletions(-) diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/environment/StandardEnvironmentFactory.java b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/environment/StandardEnvironmentFactory.java index dbcbfd3df..e067d9f9f 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/environment/StandardEnvironmentFactory.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/analysis/semantics/environment/StandardEnvironmentFactory.java @@ -210,6 +210,7 @@ private static void addStringFunctions(Environment environment) { addFunctionDeclaration(environment, "ends with", new BuiltinFunctionType(BOOLEAN, new FormalParameter<>("string", STRING), new FormalParameter<>("match", STRING))); addFunctionDeclaration(environment, "matches", new BuiltinFunctionType(BOOLEAN, new FormalParameter<>("input", STRING), new FormalParameter<>("pattern", STRING), new FormalParameter<>("flags", STRING, true, false))); addFunctionDeclaration(environment, "split", new BuiltinFunctionType(STRING_LIST, new FormalParameter<>("string", STRING), new FormalParameter<>("delimiter", STRING))); + addFunctionDeclaration(environment, "string join", new BuiltinFunctionType(STRING, new FormalParameter<>("list", STRING_LIST), new FormalParameter<>("delimiter", STRING, true, false))); } private static void addListFunctions(Environment environment) { diff --git a/dmn-core/src/main/java/com/gs/dmn/feel/synthesis/AbstractFEELToJavaVisitor.java b/dmn-core/src/main/java/com/gs/dmn/feel/synthesis/AbstractFEELToJavaVisitor.java index 530c83849..fed013734 100644 --- a/dmn-core/src/main/java/com/gs/dmn/feel/synthesis/AbstractFEELToJavaVisitor.java +++ b/dmn-core/src/main/java/com/gs/dmn/feel/synthesis/AbstractFEELToJavaVisitor.java @@ -59,6 +59,7 @@ public abstract class AbstractFEELToJavaVisitor extends AbstractAnalysisVisitor< FEEL_2_JAVA_FUNCTION.put("lower case", "lowerCase"); FEEL_2_JAVA_FUNCTION.put("upper case", "upperCase"); FEEL_2_JAVA_FUNCTION.put("string length", "stringLength"); + FEEL_2_JAVA_FUNCTION.put("string join", "stringJoin"); FEEL_2_JAVA_FUNCTION.put("years and months duration", "yearsAndMonthsDuration"); FEEL_2_JAVA_FUNCTION.put("date and time", "dateAndTime"); diff --git a/dmn-core/src/main/resources/dmn/1.3/FEELLexer.g4 b/dmn-core/src/main/resources/dmn/1.3/FEELLexer.g4 index 1bdc2d9c4..18fe1c56e 100644 --- a/dmn-core/src/main/resources/dmn/1.3/FEELLexer.g4 +++ b/dmn-core/src/main/resources/dmn/1.3/FEELLexer.g4 @@ -229,6 +229,9 @@ NAME: 'ends' WhiteSpace+ 'with' { setText("ends with"); } | + 'string' WhiteSpace+ 'join' + { setText("string join"); } + | 'start' WhiteSpace+ 'position' { setText("start position"); } | diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java index 8e707d09f..47386d329 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/AbstractStandardFEELProcessorTest.java @@ -674,6 +674,18 @@ public void testStringFunctions() { "split(\"John Doe\", \"\\\\s\")", this.lib.split("John Doe", "\\s"), this.lib.asList("John", "Doe")); + doExpressionTest(entries, "", "string join([\"a\",\"b\",\"c\"], \"_and_\")", + "FunctionInvocation(Name(string join) -> PositionalParameters(ListLiteral(StringLiteral(\"a\"),StringLiteral(\"b\"),StringLiteral(\"c\")), StringLiteral(\"_and_\")))", + "string", + "stringJoin(asList(\"a\", \"b\", \"c\"), \"_and_\")", + this.lib.stringJoin(this.lib.asList("a", "b", "c"), "_and_"), + "a_and_b_and_c"); + doExpressionTest(entries, "", "string join([\"a\",\"b\",\"c\"])", + "FunctionInvocation(Name(string join) -> PositionalParameters(ListLiteral(StringLiteral(\"a\"),StringLiteral(\"b\"),StringLiteral(\"c\"))))", + "string", + "stringJoin(asList(\"a\", \"b\", \"c\"))", + this.lib.stringJoin(this.lib.asList("a", "b", "c")), + "abc"); } @Test diff --git a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java index d0c6f513f..e2abad3b0 100644 --- a/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java +++ b/dmn-core/src/test/java/com/gs/dmn/feel/analysis/syntax/FEELLexerTest.java @@ -148,6 +148,9 @@ public void testSimpleName() { token = checkToken("ends with", NAME, "ends with"); checkPosition(token, 1, 1, 1, 9, 0, 9); + token = checkToken("string join", NAME, "string join"); + checkPosition(token, 1, 1, 1, 11, 0, 11); + token = checkToken("list contains", NAME, "list contains"); checkPosition(token, 1, 1, 1, 13, 0, 13); diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java index f8a3e5d99..907ad49d1 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/BaseStandardFEELLib.java @@ -637,6 +637,28 @@ public List split(String string, String delimiter) { } } + @Override + public String stringJoin(List list) { + try { + return this.stringLib.stringJoin(list); + } catch (Exception e) { + String message = String.format("stringJoin(%s)", list); + logError(message, e); + return null; + } + } + + @Override + public String stringJoin(List list, String delimiter) { + try { + return this.stringLib.stringJoin(list, delimiter); + } catch (Exception e) { + String message = String.format("stringJoin(%s, %s)", list, delimiter); + logError(message, e); + return null; + } + } + // // Boolean functions // diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/StandardFEELLib.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/StandardFEELLib.java index ac4a0ed2a..9f6c3635a 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/StandardFEELLib.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/StandardFEELLib.java @@ -125,6 +125,10 @@ public interface StandardFEELLib extend List split(String string, String delimiter); + String stringJoin(List list); + + String stringJoin(List list, String delimiter); + // // Boolean functions // diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/DefaultStringLib.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/DefaultStringLib.java index ce65760dc..37ddb18c5 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/DefaultStringLib.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/DefaultStringLib.java @@ -35,8 +35,10 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; public class DefaultStringLib implements StringLib { private static final ThreadLocal DECIMAL_FORMAT = ThreadLocal.withInitial(() -> new DecimalFormat("0.########")); @@ -120,6 +122,23 @@ public String substring(String string, Number startPosition) { return result; } + @Override + public String stringJoin(List list) { + return stringJoin(list, null); + } + + @Override + public String stringJoin(List list, String delimiter) { + if (list == null) { + return null; + } + if (delimiter == null) { + delimiter = ""; + } + + return list.stream().filter(Objects::nonNull).collect(Collectors.joining(delimiter)); + } + @Override public String substring(String string, Number startPosition, Number length) { if (string == null || startPosition == null || length == null) { diff --git a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/StringLib.java b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/StringLib.java index 8b40dfaf1..077951994 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/StringLib.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/feel/lib/type/string/StringLib.java @@ -42,4 +42,8 @@ public interface StringLib { Boolean matches(String input, String pattern, String flags) throws Exception; List split(String string, String delimiter); + + String stringJoin(List list); + + String stringJoin(List list, String delimiter); } diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java index 06500eb35..0b92610a0 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibExceptionsTest.java @@ -197,6 +197,12 @@ public void testSplit() { assertNull(getLib().split(null, null)); } + @Test + public void testStringJoin() { + assertNull(getLib().stringJoin(null)); + assertNull(getLib().stringJoin(null, null)); + } + @Test public void testAnd() { assertNull(getLib().and((List) null)); diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java index 7321cc80c..004aaa28c 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/BaseStandardFEELLibTest.java @@ -703,13 +703,30 @@ public void testMatches() { @Test public void testSplit() { - assertNull("", getLib().split(null, null)); - assertNull("", getLib().split("", "")); + assertNull(getLib().split(null, null)); + assertNull(getLib().split("", "")); assertEquals(getLib().asList("John", "Doe"), getLib().split("John Doe", "\\s")); assertEquals(getLib().asList("a", "b", "c", "", ""), getLib().split("a;b;c;;", ";")); } + @Test + public void testStringJoin() { + assertNull(getLib().stringJoin(null)); + assertNull(getLib().stringJoin(null, null)); + + assertEquals("a_and_b_and_c", getLib().stringJoin(makeStringList("a", "b", "c"), "_and_")); + assertEquals("abc", getLib().stringJoin(makeStringList("a", "b", "c"), "")); + assertEquals("abc", getLib().stringJoin(makeStringList("a", "b", "c"), null)); + assertEquals( "a", getLib().stringJoin(makeStringList("a"), "X")); + assertEquals("aXc", getLib().stringJoin(makeStringList("a", null, "c"), "X")); + assertEquals("", getLib().stringJoin(makeStringList(), "X")); + + assertEquals("abc", getLib().stringJoin(makeStringList("a", "b", "c"))); + assertEquals("ac", getLib().stringJoin(makeStringList("a", null, "c"))); + assertEquals("", getLib().stringJoin(makeStringList())); + } + // // Boolean functions // diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java index a8cb6078b..b08df5302 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/FEELOperatorsTest.java @@ -1060,6 +1060,14 @@ protected List makeNumberList(Object... numbers) { return result; } + protected List makeStringList(String... strings) { + List result = new ArrayList<>(); + for (String str: strings) { + result.add(str); + } + return result; + } + protected DATE makeDate(String literal) { return getLib().date(literal); } diff --git a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/stub/StringLibStub.java b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/stub/StringLibStub.java index f76ae0d77..f0a269988 100644 --- a/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/stub/StringLibStub.java +++ b/dmn-runtime/src/test/java/com/gs/dmn/feel/lib/stub/StringLibStub.java @@ -83,6 +83,16 @@ public Boolean matches(String input, String pattern, String flags) throws Except throw new DMNRuntimeException("Not supported yet"); } + @Override + public String stringJoin(List list) { + throw new DMNRuntimeException("Not supported yet"); + } + + @Override + public String stringJoin(List list, String delimiter) { + throw new DMNRuntimeException("Not supported yet"); + } + @Override public List split(String string, String delimiter) { throw new DMNRuntimeException("Not supported yet"); From 69d862c7fe688901efb33098e80ed9d10fbefd60 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Tue, 8 Aug 2023 15:23:43 +0100 Subject: [PATCH 3/6] Forward patch from 5.5.2. [#587] Add support for xerces --- dmn-core/pom.xml | 2 +- .../java/com/gs/dmn/serialization/XMLUtil.java | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dmn-core/pom.xml b/dmn-core/pom.xml index 2970ec0c1..628c05720 100644 --- a/dmn-core/pom.xml +++ b/dmn-core/pom.xml @@ -108,7 +108,7 @@ org.fitnesse fitnesse - 20211030 + 20230503 org.slf4j diff --git a/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java b/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java index 8e97ea30e..51bcfc68e 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java @@ -24,8 +24,17 @@ public class XMLUtil { public static DocumentBuilderFactory makeDocumentBuilderFactory() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); // Compliant - dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); // compliant + String attribute = null; + try { + attribute = XMLConstants.ACCESS_EXTERNAL_DTD; + dbf.setAttribute(attribute, ""); // Compliant + attribute = XMLConstants.ACCESS_EXTERNAL_SCHEMA; + dbf.setAttribute(attribute, ""); // compliant + } catch (IllegalArgumentException e) { + // This should catch a failed setAttribute feature + LOGGER.info("IllegalArgumentException was thrown. The attribute '" + attribute + + "' is probably not supported by your XML processor."); + } String feature = null; try { // This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all @@ -50,8 +59,6 @@ public static DocumentBuilderFactory makeDocumentBuilderFactory() { // Disable external DTDs as well feature = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; dbf.setFeature(feature, false); - dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - dbf.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" dbf.setXIncludeAware(false); From 0be3ed35196899210ed3cc50d1d64fb6fb97c4b1 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Tue, 8 Aug 2023 15:25:20 +0100 Subject: [PATCH 4/6] Forward patch from 5.5.2. [#589] Fix translation of rule annotations from DMN 1.2 to DMN 1.3 --- .../src/test/resources/dmn/expected/1.2/1.3/0004-lending.dmn | 3 +++ dmn-core/src/test/resources/dmn/input/1.2/0004-lending.dmn | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dmn-core/src/test/resources/dmn/expected/1.2/1.3/0004-lending.dmn b/dmn-core/src/test/resources/dmn/expected/1.2/1.3/0004-lending.dmn index ecdcb900c..eef64ca22 100644 --- a/dmn-core/src/test/resources/dmn/expected/1.2/1.3/0004-lending.dmn +++ b/dmn-core/src/test/resources/dmn/expected/1.2/1.3/0004-lending.dmn @@ -157,6 +157,9 @@ "DECLINE" + + annotation + diff --git a/dmn-core/src/test/resources/dmn/input/1.2/0004-lending.dmn b/dmn-core/src/test/resources/dmn/input/1.2/0004-lending.dmn index 476997cc0..ffaef6889 100644 --- a/dmn-core/src/test/resources/dmn/input/1.2/0004-lending.dmn +++ b/dmn-core/src/test/resources/dmn/input/1.2/0004-lending.dmn @@ -157,6 +157,9 @@ "DECLINE" + + annotation + From 97c61bb69df5f05a7d7cff121526716a56c090d8 Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Tue, 8 Aug 2023 15:26:03 +0100 Subject: [PATCH 5/6] Forward patch from 5.5.2. Change log level in jdmn-runtime to avoid verbosity. --- dmn-runtime/src/main/java/com/gs/dmn/runtime/LazyEval.java | 4 ++-- .../com/gs/dmn/runtime/listener/LoggingEventListener.java | 4 ++-- .../src/main/java/com/gs/dmn/serialization/XMLUtil.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dmn-runtime/src/main/java/com/gs/dmn/runtime/LazyEval.java b/dmn-runtime/src/main/java/com/gs/dmn/runtime/LazyEval.java index 03c44d0a9..1c20bb233 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/runtime/LazyEval.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/runtime/LazyEval.java @@ -24,7 +24,7 @@ * */ public final class LazyEval { - protected static final Logger LOGGER = LoggerFactory.getLogger(LazyEval.class); + private static final Logger LOGGER = LoggerFactory.getLogger(LazyEval.class); private T value; private boolean isValueSet = false; @@ -39,7 +39,7 @@ public T getOrCompute() { } private T compute() { - LOGGER.info("Trigger lazy evaluation"); + LOGGER.debug("Trigger lazy evaluation"); isValueSet = true; return value = supplier.get(); diff --git a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/LoggingEventListener.java b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/LoggingEventListener.java index 09bdced55..09107beaf 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/LoggingEventListener.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/runtime/listener/LoggingEventListener.java @@ -23,12 +23,12 @@ public LoggingEventListener(Logger logger) { @Override public void startDRGElement(DRGElement element, Arguments arguments) { - logger.info("Start {} '{}' with inputs '{}'", element.getElementKind().getDisplayName(), element.getName(), arguments); + logger.debug("Start {} '{}' with inputs '{}'", element.getElementKind().getDisplayName(), element.getName(), arguments); } @Override public void endDRGElement(DRGElement element, Arguments arguments, Object output, long duration) { - logger.info("End {} '{}' with output '{}' in {}ms", element.getElementKind().getDisplayName(), element.getName(), output, duration); + logger.debug("End {} '{}' with output '{}' in {}ms", element.getElementKind().getDisplayName(), element.getName(), output, duration); } @Override diff --git a/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java b/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java index 51bcfc68e..2fedd4fa7 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java @@ -32,7 +32,7 @@ public static DocumentBuilderFactory makeDocumentBuilderFactory() { dbf.setAttribute(attribute, ""); // compliant } catch (IllegalArgumentException e) { // This should catch a failed setAttribute feature - LOGGER.info("IllegalArgumentException was thrown. The attribute '" + attribute + LOGGER.debug("IllegalArgumentException was thrown. The attribute '" + attribute + "' is probably not supported by your XML processor."); } String feature = null; @@ -70,7 +70,7 @@ public static DocumentBuilderFactory makeDocumentBuilderFactory() { // of service attacks (such as billion laughs or decompression bombs via "jar:") are a risk." } catch (ParserConfigurationException e) { // This should catch a failed setFeature feature - LOGGER.info("ParserConfigurationException was thrown. The feature '" + feature + LOGGER.debug("ParserConfigurationException was thrown. The feature '" + feature + "' is probably not supported by your XML processor."); } From 07e8bdf2ac25061a55c9acc5255fe0a2661ac53b Mon Sep 17 00:00:00 2001 From: Octavian Patrascoiu Date: Tue, 8 Aug 2023 15:26:42 +0100 Subject: [PATCH 6/6] Forward patch from 5.5.2. Force default DocumentBuilderFactory to improve performance --- .../src/main/java/com/gs/dmn/serialization/XMLUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java b/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java index 2fedd4fa7..289b043d5 100644 --- a/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java +++ b/dmn-runtime/src/main/java/com/gs/dmn/serialization/XMLUtil.java @@ -12,6 +12,7 @@ */ package com.gs.dmn.serialization; +import com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +24,8 @@ public class XMLUtil { private static final Logger LOGGER = LoggerFactory.getLogger(XMLUtil.class); public static DocumentBuilderFactory makeDocumentBuilderFactory() { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory dbf = new DocumentBuilderFactoryImpl(); + String attribute = null; try { attribute = XMLConstants.ACCESS_EXTERNAL_DTD;