This is an automated email from the ASF dual-hosted git repository.

tzimanyi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git


The following commit(s) were added to refs/heads/main by this push:
     new eb2f4f6162 [incubator-kie-issues#875] DMN - Do not create an exception 
when property is not defined. (#5672)
eb2f4f6162 is described below

commit eb2f4f61628030890c23fa960e094a4ec08ec9cc
Author: Justin Reardon <[email protected]>
AuthorDate: Mon Feb 12 09:58:09 2024 -0500

    [incubator-kie-issues#875] DMN - Do not create an exception when property 
is not defined. (#5672)
---
 .../src/main/java/org/kie/dmn/feel/util/EvalHelper.java          | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java 
b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
index 4fa56ed075..452b3b2db1 100644
--- a/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
+++ b/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
@@ -287,6 +287,11 @@ public class EvalHelper {
 
     public static class PropertyValueResult implements 
FEELPropertyAccessible.AbstractPropertyValueResult {
 
+        // This exception is used to signal an undefined property for 
notDefined(). This method may be many times when
+        // evaluating a decision, so a single instance is being cached to 
avoid the cost of creating the stack trace
+        // each time.
+        private static final Exception undefinedPropertyException = new 
UnsupportedOperationException("Property was not defined.");
+
         private final boolean defined;
         private final Either<Exception, Object> valueResult;
 
@@ -296,7 +301,7 @@ public class EvalHelper {
         }
 
         public static PropertyValueResult notDefined() {
-            return new PropertyValueResult(false, Either.ofLeft(new 
UnsupportedOperationException("Property was not defined.")));
+            return new PropertyValueResult(false, 
Either.ofLeft(undefinedPropertyException));
         }
 
         public static PropertyValueResult of(Either<Exception, Object> 
valueResult) {
@@ -782,4 +787,4 @@ public class EvalHelper {
                     '}';
         }
     }
-}
\ No newline at end of file
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to