GH-118: Fix auto-wire ambiguity in the HttpSupplierConfiguration

Fixes: https://github.com/spring-cloud/spring-functions-catalog/issues/118

* Use `toReactivePublisher(true)` instead of manual lifecycle control for the `WebFluxInboundEndpoint`
This commit is contained in:
Artem Bilan
2024-12-19 13:38:17 -05:00
parent 9bc93a9371
commit 9b1754bdca

View File

@@ -68,23 +68,18 @@ public class HttpSupplierConfiguration {
.codecConfigurer(serverCodecConfigurer)
.crossOrigin((crossOrigin) -> crossOrigin.origin(httpSupplierProperties.getCors().getAllowedOrigins())
.allowedHeaders(httpSupplierProperties.getCors().getAllowedHeaders())
.allowCredentials(httpSupplierProperties.getCors().getAllowCredentials()))
.autoStartup(false))
.allowCredentials(httpSupplierProperties.getCors().getAllowCredentials())))
.enrichHeaders((headers) -> headers.headerFunction(MessageHeaders.CONTENT_TYPE,
(message) -> (MediaType.APPLICATION_FORM_URLENCODED
.equals(message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MediaType.class)))
? MediaType.APPLICATION_JSON : null,
true))
.toReactivePublisher();
.toReactivePublisher(true);
}
@Bean
public Supplier<Flux<Message<byte[]>>> httpSupplier(Publisher<Message<byte[]>> httpRequestPublisher,
WebFluxInboundEndpoint webFluxInboundEndpoint) {
return () -> Flux.from(httpRequestPublisher)
.doOnSubscribe((subscription) -> webFluxInboundEndpoint.start())
.doOnTerminate(webFluxInboundEndpoint::stop);
public Supplier<Flux<Message<byte[]>>> httpSupplier(Publisher<Message<byte[]>> httpSupplierFlow) {
return () -> Flux.from(httpSupplierFlow);
}
}