quarkus: Either RESTEasy Reactive/REST Client Reactive swallow errors in some scenarios, very difficult to debug

Describe the bug

The actual error being throw under the hood was:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.HashSet<org.acme.CurrentWeather>` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (ByteArrayInputStream); line: 1, column: 1]

But between the fact that Quarkus generates a lot of code, and the reactive/multithreaded bit, debugging this and trying to navigate the source + callstack was somewhat of a nightmare because:

  • For a lot of the source, there’s no file it would show in the IDE for the relevant code bits
  • The chain of calls/indirection can be particularly deep

quarkus-reactive-not-surfacing-errors

But with this code/endpoint:

@JsonIgnoreProperties(ignoreUnknown = true)
class CurrentWeather {
    public String description;
    public int temp;
    public int feels_like;
    public int wind_speed;
}

@RegisterRestClient(baseUri = "http://api.openweathermap.org/data/2.5")
interface WeatherService {

    enum MeasurementKind { standard, metric, imperial }

    // We can fake/pretend these are path params and it winds up a bit clearer
    @GET
    @Path("/weather?q={city},{country}&appid={apiKey}&units={units}")
    Set<CurrentWeather> getWeatherByCityAndCountry(String city,
                                                   String country,
                                                   String apiKey,
                                                   String units);
}

public class Thing {
    private static final Logger log = Logger.getLogger(SomePage.class);
    
    @RestClient WeatherService weatherApi;
    @Inject Configuration config;

    @GET
    @Path("/route")
    @Blocking
    public Set<CurrentWeather> getWeatherExample1() {
        log.info("called!!!");
        var results = weatherApi.getWeatherByCityAndCountry(
                "Miami", "US",
                config.openWeatherMapApiKey,
                WeatherService.MeasurementKind.imperial.name());
        log.info("results = ");
        log.info(results);
        return results;
    }
}

Nothing is ever logged past the initial called!!! 🙁 Very confusing

image

image

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

Quarkus v2.1.2-final

plugins {
    java
    id("io.quarkus")
}

repositories {
    mavenCentral()
    mavenLocal()
}

val quarkusPlatformGroupId: String by project
val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project

dependencies {
    implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
    implementation("io.quarkus:quarkus-arc")
    implementation("io.quarkus:quarkus-resteasy-reactive")
    implementation("io.quarkus:quarkus-resteasy-reactive-qute")
    implementation("io.quarkus:quarkus-resteasy-reactive-jackson")
    implementation("io.quarkus:quarkus-rest-client-reactive")
    implementation("io.quarkus:quarkus-rest-client-reactive-jackson")

    testImplementation("io.quarkus:quarkus-junit5")
    testImplementation("io.rest-assured:rest-assured")
}

group = "org.acme"
version = "1.0.0-SNAPSHOT"

java {
    sourceCompatibility = JavaVersion.VERSION_16
    targetCompatibility = JavaVersion.VERSION_16
}

tasks.withType<JavaCompile> {
    options.encoding = "UTF-8"
    options.compilerArgs.add("-parameters")
}

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Yeah absolutely, I should have provided it in the first place.

I will feel quite an ass if it’s user-error, but I will immediately put together a reproduction, that’s no issue (it was a teaching app for showing Quarkus to a CS student anyways using OpenWeather API I wrote – it’s tiny and has 2 files.)

Will try to revert it back to the state that broke it and then post it here as a zip. You Quarkus’ers/Redhatters are, as usual, just the best of people ❤️

Yeah, it’s sometimes hard to understand where the Jackson errors actually mean in practice. That said, we could likely add some intelligence in Quarkus (perhaps only in dev-mode) to help users, but it would probably be very fragile…