GH-1134: Fix NPE in SimpleFunctionRegistry#isExtractPayload()

Resolves https://github.com/spring-cloud/spring-cloud-function/issues/1134
This commit is contained in:
Soby Chacko
2024-04-09 16:17:05 -04:00
parent 17dbaa0ca7
commit d38ab942bd

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2023 the original author or authors. * Copyright 2019-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -1175,14 +1175,13 @@ public class SimpleFunctionRegistry implements FunctionRegistry {
if (ObjectUtils.isArray(payload)) { if (ObjectUtils.isArray(payload)) {
payload = CollectionUtils.arrayToList(payload); payload = CollectionUtils.arrayToList(payload);
} }
if (payload instanceof Collection && !CollectionUtils.isEmpty((Collection<?>) payload) if (payload instanceof Collection && !CollectionUtils.isEmpty((Collection<?>) payload)) {
&& Message.class.isAssignableFrom(CollectionUtils.findCommonElementType((Collection<?>) payload))) { Class<?> commonElementType = CollectionUtils.findCommonElementType((Collection<?>) payload);
return true; if (commonElementType != null && Message.class.isAssignableFrom(commonElementType)) {
return true;
}
} }
if (this.containsRetainMessageSignalInHeaders(message)) { return !this.containsRetainMessageSignalInHeaders(message);
return false;
}
return true;
} }
/** /**