Closed kdvolder closed 2 years ago
Sadly still no reproducible sample. I did try to create a 'toy' version of our app but couldn't reproduce the error with it.
However there is some good news. I have found a workaround for the issue and maybe this can provide some hint as to the root cause of the problem.
In our code we have the following bean definition:
@Bean
RSocketRequester rSocketRequester(RSocketRequester.Builder rSocketRequesterBuilder, AppLiveViewClientProperties props, List<AppLiveViewClientController> clientSideControllers) {
String protocal = props.isSslDisabled() ? "ws://" : "wss://";
URI uri = URI.create(protocal+props.getHost()+":"+props.getPort());
RSocketStrategies strategies = RSocketStrategies.builder()
.encoders(encoders -> {
encoders.add(new Jackson2CborEncoder());
encoders.add(new Jackson2JsonEncoder()); // <-- Added: Spring native workaround
})
.decoders(decoders -> {
decoders.add(new Jackson2CborDecoder());
decoders.add(new Jackson2JsonDecoder()); // <-- Added: Spring native workaround
})
.metadataExtractorRegistry(r -> r.metadataToExtract(MimeTypes.INSTANCE_ID, String.class, RSocketHeaders.INSTANCE_ID))
.metadataExtractorRegistry(r -> r.metadataToExtract(MimeTypes.ACTUATOR_PROXY_REQUEST, ActuatorProxyRequest.class, RSocketHeaders.ACTUATOR_PROXY_REQUEST))
.routeMatcher(new PathPatternRouteMatcher())
.build();
SocketAcceptor responder =
RSocketMessageHandler.responder(strategies, clientSideControllers.toArray());
log.info("Creating RSocket connector to {}:{}", props.getHost(), props.getPort());
log.info("Creating RSocket connector url: {}", uri);
return rSocketRequesterBuilder
.rsocketConnector(connector -> connector
.fragment(10_000_000)
.reconnect(Retry.backoff(Long.MAX_VALUE, Duration.ofSeconds(2)))
.acceptor(responder))
.websocket(uri);
}
The lines marked with a //Added...
comment are what makes it work somehow. I am not totally sure why.
Perhaps without the -DspringAot=true
we automatically get a json encoder? Or perhaps the Cbor encoder somehow forgets how to encode a 'solitary' boolean value when we add springAot
flag.
Worth to double check with Spring Boot 3 milestone when the support will be advanced enough to test this kind of use case. Without a reproducer, I will just close the issue on Spring Native side, thanks for your effort to try to create one.
I will try to produce a minimally reproducing sample, but it is hard extract this from the code where I am encountering it. When I have the sample I will attach it here.
In the mean time let me describe what's happening.
I am updating an app that uses RSocket and has a controller method like this:
Things broke in the native-compiled version of the app after upgrading to Spring Boot 2.6.7 from 2.5.12 and spring native to 0.11.4 from 0.10.6.
I am trying to collect data using the native trace agent. And I am running the app using an argument like:
Strangely the
env/probe
endpoint implemented by the method shown above does not work and produces`No encoder for java.lang.Boolean
MessagingException (full trace at end of this message). This appears to be caused somehow by the-DspringAot=true
argument. When this argument is changed to-DspringAot=false
then all works as it should.Stacktrace: