First off, let me just say that working with CXF is always absolutely great! 
Everything about the API, from REST to OAuth, always seems to just work. If
I do need to do any digging into the API it is straight forward and sensible
and I have never had any problems integrating it with any of my projects. 
Keep up the great work on this package!

Now, my question...  

*Why is it whenever I hit a Mono resource that returns empty() it appears to
hang and never complete?*  Other reactor resources that return values work
fine and Fluxes that work empty work fine too.

I am using the latest versions of CXF (3.2.7), JDK11, Spring Boot (2.1.2),
Undertow (through Spring Boot but NIO is updated based on
https://issues.jboss.org/browse/UNDERTOW-1355 to get around JDK9+ issues),
and Project Reactor.

I am trying to integrate Mono/Flux resources using CXF, not SpringBoot
controllers/handlers, because we already use CXF for regular REST resources. 
Also, I am hoping by using CXF + REST + Project Reactor + Undertow I can
expose a hybrid of REST and Reactive resources through Undertow only and not
require using Netty.

I have I believe configured CXF with the ReactorCustomizer correctly as such
using a custom AutoConfiguration that extends the
AbstractSpringComponentScanServer:

@Override
protected void finalizeFactorySetup(final JAXRSServerFactoryBean factory)
{
    //Update the provider
    final JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
    jsonProvider.setMapper(objectMapper);
    factory.setProvider(jsonProvider);

    //Customize the server for reactive operations
    final ReactorCustomizer customizer = new ReactorCustomizer();
    customizer.customize(factory);
    log.debug("Customized JAX-RS with reactive extensions");
}

My reactive resources that return Fluxes or Monos work /if/ they contain a
value (i.e. not empty).  Whenever I try to return a Mono<?> that is
Mono.empty() I see the request complete like the others (through the CXF
logs) but it appears the thread just hangs and it never returns.

Tracing into the ReactorInvoker even looks like it completes successfully...

I have two simple test methods I can use to replicate this with.  "/test1"
hangs but "/test2" returns an empty JSON list even though it returns
Flux.empty().

@GET
@Path("/test1")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public Mono<Map> getMono()
{
    return Mono.empty();
}

@GET
@Path("/test2")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public Flux<String> getFlux()
{
    return Flux.empty();
}

Any of my Mono or Flux resources that do return with values work fine...

I am still pretty new to Project Reactor so maybe this is an invalid way of
returning empty() in a resource but I do need to know if I am doing this
correct or if there is something special about how CXF Reactor handles the
"empty" response or if I need to handle additional steps in the event the
response is empty (I need to do this regardless but for my test empty() was
quick and dirty).

Thanks.



--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Reply via email to