Skip to content

Commit 9c791f5

Browse files
authored
Handling null model in conversion methods (#1225)
This is a follow up of #1222 Signed-off-by: fjtirado <ftirados@redhat.com>
1 parent f263728 commit 9c791f5

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

  • experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func

experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaFuncUtils.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,24 @@ static WorkflowPredicate from(WorkflowApplication application, PredicateContaine
3636
}
3737

3838
static <T> T convertT(WorkflowModel model, Optional<Class<T>> inputClass) {
39-
return inputClass
40-
.map(
41-
c ->
42-
model
43-
.as(c)
44-
.orElseThrow(
45-
() ->
46-
new IllegalArgumentException(
47-
"Model " + model + " cannot be converted to type " + c)))
48-
.orElseGet(() -> (T) model.asJavaObject());
39+
return model.isNull()
40+
? null
41+
: inputClass
42+
.map(
43+
c ->
44+
model
45+
.as(c)
46+
.orElseThrow(
47+
() ->
48+
new IllegalArgumentException(
49+
"Model " + model + " cannot be converted to type " + c)))
50+
.orElseGet(() -> (T) model.asJavaObject());
4951
}
5052

5153
static Object convert(WorkflowModel model, Optional<Class<?>> inputClass) {
54+
if (model.isNull()) {
55+
return null;
56+
}
5257
return inputClass.isPresent()
5358
? model
5459
.as(inputClass.orElseThrow())

0 commit comments

Comments
 (0)