eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.3k stars 2.08k forks source link

config.json RequestOptions mapping no longer working in Vertx 3.9.5 and Jackson 2.10.4 or 2.11.3 #3735

Closed goldel777b closed 3 years ago

goldel777b commented 3 years ago

Questions

Do not use this issue tracker to ask questions, instead use one of these channels. Questions will likely be closed without notice.

Version

Vertx 3.9.5 and Jackson 2.10.4 or 2.11.3

Context

I encountered an exception which looks suspicious while upgrading from Vertx 3.6.3 and Jackson 2.9.3

Do you have a reproducer?

A reproducer is a simple project hosted on GitHub (or another forge supporting git clone operation) that has a build file that can be executed to reproduce the issue.

Reproducers are very helpful for contributors and will likely help them fixing your bug faster.

Steps to reproduce

  1. create unit tests as follows and run:

    public void checkRequestOptionsDeserialize() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); TypeFactory typeFactory = mapper.getTypeFactory(); JavaType javaType = typeFactory.constructType(RequestOptions.class); RequestOptions requestOptions = new RequestOptions(); String json = mapper.writeValueAsString(requestOptions); System.out.println(json);

    WebClientApiConfigurationTest deserializedObject = mapper.readValue(json, javaType);

    }

Error results:

Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params) at [Source: (String)"{"host":"localhost","port":80,"ssl":null,"uri":"","headers":null}"; line: 1, column: 1] com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params) at [Source: (String)"{"host":"localhost","port":80,"ssl":null,"uri":"","headers":null}"; line: 1, column: 1] at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:309)

2) 2nd test

@Test
public void checkRequestOptionssnsCanDeserialize() throws JsonProcessingException {
    ObjectMapper mapper = new ObjectMapper();
    TypeFactory typeFactory = mapper.getTypeFactory();
    JavaType javaType =  typeFactory.constructType(RequestOptions.class);

    AtomicReference<Throwable> causeRef = new AtomicReference<>();
    if (! mapper.canDeserialize(javaType, causeRef)) {
        throw new RuntimeException(causeRef.get());
    }
}

results:

com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params) java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params) at com.nbcuni.oa.mam.workorder.jackson.JacksonOverloadedSettersTest.checkRequestOptionssnsCanDeserialize(JacksonOverloadedSettersTest.java:154) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.lang.Thread.run(Thread.java:748) Caused by: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params)

Extra

https://github.com/FasterXML/jackson-databind/issues/2757

vietj commented 3 years ago

can you describe the issue you are observing in the issue ?

goldel777b commented 3 years ago

Hi Julien,

I indicated the types of error messages I've been getting in the bug report. See below. It seems to be related to another jackson issue (url below) - in general it looks like Jackson can no longer determine which setAll to use (even though I don't think it is being called in the actually deserialization.

Error results:

Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params)at [Source: (String)"{"host":"localhost","port":80,"ssl":null,"uri":"","headers":null}"; line: 1, column: 1]

com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params)java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "all": io.vertx.core.MultiMap#setAll(1 params) vs io.vertx.core.MultiMap#setAll(1 params)

This may be related to a similar issue reported here:

FasterXML/jackson-databind#2757 https://github.com/FasterXML/jackson-databind/issues/2757

Regards,

Lori Golden

On Tue, Jan 5, 2021 at 12:52 PM Julien Viet notifications@github.com wrote:

can you describe the issue you are observing in the issue ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eclipse-vertx/vert.x/issues/3735#issuecomment-754794700, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARWC4W52QZ5J56WAW3ATBEDSYNGWTANCNFSM4VVRZQIQ .

tsegismont commented 3 years ago

RequestOptions instances are not meant to converted to/from JSON directly with ObjectMapper. Instead, you can use the toJson method and the constructor that takes a JsonObject parameter.