Skip to content

Commit

Permalink
[incubator-kie-issues#875] DMN - Do not create an exception when prop…
Browse files Browse the repository at this point in the history
…erty is not defined. (apache#5672)
  • Loading branch information
jmreardon-yoppworks authored and rgdoliveira committed Mar 11, 2024
1 parent d19d875 commit f6a449b
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ public static String unescapeString(String text) {

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;

Expand All @@ -296,7 +301,7 @@ private PropertyValueResult(boolean isDefined, Either<Exception, Object> value)
}

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) {
Expand Down Expand Up @@ -782,4 +787,4 @@ public String toString() {
'}';
}
}
}
}

0 comments on commit f6a449b

Please sign in to comment.