[
https://issues.apache.org/jira/browse/CXF-9185?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Freeman Yue Fang reassigned CXF-9185:
-------------------------------------
Assignee: Freeman Yue Fang
> NPE after removing a property from a JAX-RS Client
> --------------------------------------------------
>
> Key: CXF-9185
> URL: https://issues.apache.org/jira/browse/CXF-9185
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 4.1.4
> Reporter: Sola-ris
> Assignee: Freeman Yue Fang
> Priority: Major
>
> Removing a property from a JAX-RS Client via property("name", nulll) causes a
> NullPointerException when calling the request method on a WebTarget created
> from the client.
> *To Reproduce:*
> {code:java}
> try (Client client = ClientBuilder.newClient()) {
> client.property("greeting", "hello");
> client.property("greeting", null);
> client.target("").request().get().close();
> }
> {code}
> *Stacktrace:*
> {code:java}
> java.lang.RuntimeException: java.lang.NullPointerException
> at
> org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:242)
> at
> org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl.initTargetClientIfNeeded(ClientImpl.java:363)
> at
> org.apache.cxf.jaxrs.client.spec.ClientImpl$WebTargetImpl.request(ClientImpl.java:259)
> at
> org.example.RemovePropertyReproducerTest.testRemoveProperty(RemovePropertyReproducerTest.java:16)
> at java.base/java.lang.reflect.Method.invoke(Method.java:580)
> at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
> at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
> Caused by: java.lang.NullPointerException
> at
> java.base/java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
> at
> java.base/java.util.concurrent.ConcurrentHashMap.putAll(ConcurrentHashMap.java:1089)
> at
> org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.createEndpoint(AbstractJAXRSFactoryBean.java:224)
> at
> org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:229)
> ... 6 more
> {code}
> [Executable
> Reproducer|https://github.com/Sola-ris/cxf-reproducers/blob/master/src/test/java/org/example/RemovePropertyReproducerTest.java]
> From looking at it the Debugger, the property isn't actually removed but the
> value is set to null instead. The reason seems to be in [ConfigurationImpl
> Line
> 170|https://github.com/apache/cxf/blob/main/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java#L170]
> where the name is checked for null instead of the value
--
This message was sent by Atlassian Jira
(v8.20.10#820010)