snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Dev mode fails to reload classes when using reactive rest client #341

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug

We are using resteasy reactive and the reactive rest client in Quarkus 1.13.4.Final, gradle and Kotlin. Everytime the quarkus dev mode reloads the code, Quarkus is broken and we have to restart it.

We were able to break it down to a small reproducer. The problem seems to appear, when we have a POST resource that receives a DTO in the body and passes this dto to a rest client call that receives a generified response (best take a look at the ReactiveResource:getClient() method in the reproducer). When the service is freshly started gradlew quarkusDev, it all works fine. However, as soon as you change something and quarkus recompiles the code on the next call, it is broken.

We added a logging of the received object and there we get the following error:

2021-05-19 15:52:52,547 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (vert.x-eventloop-thread-10) Request failed: java.lang.ClassCastException: class org.acme.dto.ApiResponse cannot be cast to class org.acme.dto.ApiResponse (org.acme.dto.ApiResponse is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @df5f5c0; org.acme.dto.ApiResponse is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @1091b449)
    at org.acme.ReactiveResource$getClient$1.apply(ReactiveResource.kt:18)
    at io.smallrye.context.impl.wrappers.SlowContextualFunction.apply(SlowContextualFunction.java:21)
...

When we do not add the logging, the response from the resource is just empty.

Please note: In the reproducer, we use the rest client to call the same quarkus service again. This is just to make the reproducer self contained. We also experienced this when calling another service.

Expected behavior

Quarkus Dev Mo

Actual behavior

The classes do not seem to be reloaded correctly.

To Reproduce

  1. Download reproducer and unzip 2021-05-19-restclient-dev-mode.zip
  2. In the project run ./gradlew quarkusDev
  3. Call the endpoint with
    curl --location --request POST 'localhost:8080/client' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "name" : "Bernd"
    }'
  4. Change anything in the code to cause a recompile on the next call
  5. Call the service again and observe the error in the log.

https://github.com/quarkusio/quarkus/issues/17359


$upstream:17359$