Skip to content

Commit d38ab94

Browse files
committed
GH-1134: Fix NPE in SimpleFunctionRegistry#isExtractPayload()
Resolves #1134
1 parent 17dbaa0 commit d38ab94

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1175,14 +1175,13 @@ private boolean isExtractPayload(Message<?> message, Type type) {
11751175
if (ObjectUtils.isArray(payload)) {
11761176
payload = CollectionUtils.arrayToList(payload);
11771177
}
1178-
if (payload instanceof Collection && !CollectionUtils.isEmpty((Collection<?>) payload)
1179-
&& Message.class.isAssignableFrom(CollectionUtils.findCommonElementType((Collection<?>) payload))) {
1180-
return true;
1181-
}
1182-
if (this.containsRetainMessageSignalInHeaders(message)) {
1183-
return false;
1178+
if (payload instanceof Collection && !CollectionUtils.isEmpty((Collection<?>) payload)) {
1179+
Class<?> commonElementType = CollectionUtils.findCommonElementType((Collection<?>) payload);
1180+
if (commonElementType != null && Message.class.isAssignableFrom(commonElementType)) {
1181+
return true;
1182+
}
11841183
}
1185-
return true;
1184+
return !this.containsRetainMessageSignalInHeaders(message);
11861185
}
11871186

11881187
/**

0 commit comments

Comments
 (0)