GH-500 Fix NPE in FunctionEndpointInitializer

This ensures that posting to the consumer does not result in NPE given that there is no body

Resolves #500
This commit is contained in:
Oleg Zhurakousky
2020-06-10 19:44:27 +02:00
parent af192a5adf
commit b4e5315a10

View File

@@ -240,13 +240,12 @@ class FunctionEndpointFactory {
.flatMap(content -> this.processor.post(wrapper, content, false));
return stream.flatMap(entity -> {
return status(entity.getStatusCode()).headers(headers -> headers.addAll(entity.getHeaders()))
.body(Mono.just((T) entity.getBody()), outputType);
.body(entity.hasBody() ? Mono.just((T) entity.getBody()) : Mono.empty(), outputType);
});
})
.andRoute(GET("/**"), request -> {
Object functionComponent = extract(request);
Class<T> outputType = (Class<T>) this.inspector.getOutputType(functionComponent);
// if (functionComponent instanceof Supplier) {
if (((FunctionInvocationWrapper) functionComponent).isSupplier()) {
Supplier<? extends Flux<?>> supplier = (Supplier<Flux<?>>) functionComponent;
FunctionWrapper wrapper = RequestProcessor.wrapper(null, null, supplier);