wmedvede commented on code in PR #3250:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3250#discussion_r1383000600


##########
kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/TimeoutsConfigResolver.java:
##########
@@ -45,26 +47,30 @@ public static String resolveEventTimeout(State state, 
Workflow workflow) {
                     String.format(INVALID_EVENT_TIMEOUT_FOR_STATE_ERROR,
                             timeouts.getEventTimeout(),
                             state.getName(),
-                            workflow.getName()));
+                            workflow.getName()),
+                    workflow.getExpressionLang());
             return timeouts.getEventTimeout();
         } else {
             timeouts = workflow.getTimeouts();
             if (timeouts != null && timeouts.getEventTimeout() != null) {
                 validateDuration(timeouts.getEventTimeout(),
                         String.format(INVALID_EVENT_TIMEOUT_FOR_WORKFLOW_ERROR,
                                 timeouts.getEventTimeout(),
-                                workflow.getName()));
+                                workflow.getName()),
+                        workflow.getExpressionLang());
                 return timeouts.getEventTimeout();
             }
         }
         return null;
     }
 
-    private static void validateDuration(String value, String message) {
-        try {
-            Duration.parse(value);
-        } catch (DateTimeParseException e) {
-            throw new IllegalArgumentException(message, e);
+    private static void validateDuration(String value, String message, String 
exprLanguage) {
+        if (!ExpressionHandlerFactory.get(exprLanguage, value).isValid()) {
+            try {
+                Duration.parse(value);
+            } catch (DateTimeParseException e) {
+                throw new IllegalArgumentException(message, e);

Review Comment:
   Not sure if we have a way to know if a value "looks like" an expression 
rather than a Duration directly and react consequently.  But in this code here, 
if the expression is invalid, what users will see, is a DataTimeParseError, 
which might be wrong in case of an expression with errors.
   
   IDK, if we have an expression like:   "...value"  , users will see a date 
time parse exception.



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