Skip to content

Commit

Permalink
Improve reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
opatrascoiu committed Sep 10, 2024
1 parent 5c21278 commit 7f695fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@ public Duration durationDivideNumber(Duration first, BigDecimal second) {
if (isYearsAndMonthsDuration(first)) {
Long firstValue = monthsValue(first);
BigDecimal months = divideNumbers(firstValue, second);
if (months == null) {
throw new DMNRuntimeException(String.format("Cannot divide '%s' by '%s'", first, second));
}
return XMLDurationFactory.INSTANCE.yearMonthFromValue(months.longValue());
} else if (isDaysAndTimeDuration(first)) {
Long firstValue = secondsValue(first);
BigDecimal seconds = divideNumbers(firstValue, second);
if (seconds == null) {
throw new DMNRuntimeException(String.format("Cannot divide '%s' by '%s'", first, second));
}
return XMLDurationFactory.INSTANCE.dayTimeFromValue(seconds.longValue());
} else {
throw new DMNRuntimeException(String.format("Cannot divide '%s' by '%s'", first, second));
Expand Down
2 changes: 1 addition & 1 deletion dmn-runtime/src/main/java/com/gs/dmn/runtime/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public String toString() {
Set set = this.map.keySet();
if (set != null && !set.isEmpty() && set.iterator().next() instanceof String) {
ArrayList<String> orderedKeys = new ArrayList<>(set);
Collections.sort(orderedKeys, (s1, s2) -> s1 != null && s2 != null ? s1.compareTo(s1) : -1);
orderedKeys.sort((s1, s2) -> s1 != null && s2 != null ? s1.compareTo(s2) : -1);
StringBuilder result = new StringBuilder("{");
for(int i=0; i<orderedKeys.size(); i++) {
Object key = orderedKeys.get(i);
Expand Down

0 comments on commit 7f695fe

Please sign in to comment.