diff --git a/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonDeserializerFactory.java b/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonDeserializerFactory.java index 73d843f80d00a..fa1fdb002bf0a 100644 --- a/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonDeserializerFactory.java +++ b/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonDeserializerFactory.java @@ -156,6 +156,9 @@ * Map.Entry entry = (Map.iterator) var3.next(); * String field = (String) entry.getKey(); * JsonNode jsonNode = (JsonNode) entry.getValue(); + * if (jsonNode.isNull()) { + * continue; + * } * switch (field) { * case "content": * dataItem.setContent(context.readTreeAsValue(jsonNode, this.valueTypes[0])); @@ -240,10 +243,13 @@ private boolean deserializeObject(ClassInfo classInfo, ResultHandle objHandle, C .invokeInterfaceMethod(ofMethod(Map.Entry.class, "getKey", Object.class), mapEntry); ResultHandle fieldValue = loopCreator.checkCast(loopCreator .invokeInterfaceMethod(ofMethod(Map.Entry.class, "getValue", Object.class), mapEntry), JsonNode.class); - Switch.StringSwitch strSwitch = loopCreator.stringSwitch(fieldName); + + loopCreator.ifTrue(loopCreator.invokeVirtualMethod(ofMethod(JsonNode.class, "isNull", boolean.class), fieldValue)) + .trueBranch().continueScope(loopCreator); Set deserializedFields = new HashSet<>(); ResultHandle deserializationContext = deserialize.getMethodParam(1); + Switch.StringSwitch strSwitch = loopCreator.stringSwitch(fieldName); return deserializeFields(classCreator, classInfo, deserializationContext, objHandle, fieldValue, deserializedFields, strSwitch, parseTypeParameters(classInfo, classCreator)); } diff --git a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java index 8aa2a009e8418..1c59ae89d210c 100644 --- a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java +++ b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java @@ -675,6 +675,24 @@ public void testEcho() { .body("veterinarian.title", Matchers.nullValue()); } + @Test + public void testEchoWithNullString() { + RestAssured + .with() + .body("{\"publicName\":null,\"veterinarian\":{\"name\":\"Dolittle\"},\"age\":5,\"vaccinated\":true}") + .contentType("application/json; charset=utf-8") + .post("/simple/dog-echo") + .then() + .statusCode(200) + .contentType("application/json") + .body("publicName", Matchers.nullValue()) + .body("privateName", Matchers.nullValue()) + .body("age", Matchers.is(5)) + .body("vaccinated", Matchers.is(true)) + .body("veterinarian.name", Matchers.is("Dolittle")) + .body("veterinarian.title", Matchers.nullValue()); + } + @Test public void testEchoWithMissingPrimitive() { RestAssured