ChinchuAjith commented on code in PR #6299:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6299#discussion_r2057611093


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/CeilingFunction.java:
##########
@@ -45,11 +48,16 @@ public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" 
) BigDecimal n, @Para
         if ( scale == null ) {
             return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "cannot be null"));
         }
-        // Based on Table 76: Semantics of numeric functions, the scale is in 
range −6111 .. 6176
-        if (scale.compareTo(BigDecimal.valueOf(-6111)) < 0 || 
scale.compareTo(BigDecimal.valueOf(6176)) > 0) {
-            return FEELFnResult.ofError(new 
InvalidParametersEvent(Severity.ERROR, "scale", "must be in range between -6111 
to 6176."));
-        }
-
-        return FEELFnResult.ofResult( n.setScale( scale.intValue(), 
RoundingMode.CEILING ) );
+        Optional<Integer> scaleObj = 
NumberEvalHelper.coerceIntegerNumber(scale);
+        AtomicReference<FEELFnResult<BigDecimal>> toReturn = new 
AtomicReference<>();

Review Comment:
   Not really a performance issue in most cases. AtomicReference is very 
lightweight. Unless you're creating tons of them in a tight loop or on a 
critical hot path, performance impact is negligible. I believe AtomicReference 
is used here because the result needs to be assigned within a lambda 
expression, which doesn’t allow direct modification of local variables. Also, 
returning Optional<Integer> is generally preferred over null as it makes the 
absence of a value explicit and helps avoid potential NullPointerExceptions.  
Correct me if i am wrong. @gitgabrio ,Curious to hear your take on this! 👀



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