This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/4.1.x-fixes by this push:
     new 31aa55197e [CXF-9185]NPE after removing a property from a JAX-RS 
Client (#2769)
31aa55197e is described below

commit 31aa55197e2c2a8b7f4ff6a02b94b337cdc1fa69
Author: Freeman(Yue) Fang <[email protected]>
AuthorDate: Wed Dec 3 12:46:32 2025 -0500

    [CXF-9185]NPE after removing a property from a JAX-RS Client (#2769)
    
    (cherry picked from commit 10a72fb4c7372b8c794abd061578892f948dbfc1)
---
 .../org/apache/cxf/jaxrs/impl/ConfigurationImpl.java |  3 +++
 .../systest/jaxrs/JAXRS20ClientServerBookTest.java   | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
index 0eecfd5bf0..ac1e0fa481 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
@@ -168,6 +168,9 @@ public class ConfigurationImpl implements Configuration {
 
     public void setProperty(String name, Object value) {
         if (name == null) {
+            throw new NullPointerException("Property name must not be null");
+        }
+        if (value == null) {
             props.remove(name);
         } else {
             props.put(name, value);
diff --git 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index 5159ee3d42..05bd9bc754 100644
--- 
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++ 
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -320,6 +320,26 @@ public class JAXRS20ClientServerBookTest extends 
AbstractBusClientServerTestBase
         assertEquals(124L, book.getId());
         assertEquals("b", r.getHeaderString("a"));
     }
+    
+    @Test
+    public void testRemoveProperty() {
+        String address = "http://localhost:"; + PORT + "/bookstore/{a}";
+        Client client = ClientBuilder.newClient();
+        client.property("greeting", "hello");
+        client.property("greeting", null);
+        client.register((Object)ClientFilterClientAndConfigCheck.class);
+        client.register(new BTypeParamConverterProvider());
+        client.property("clientproperty", "somevalue");
+        WebTarget webTarget = client.target(address).path("{b}")
+            .resolveTemplate("a", "bookheaders").resolveTemplate("b", 
"simple");
+        Invocation.Builder builder = 
webTarget.request("application/xml").header("a", new BType());
+
+        Response r = builder.get();
+        Book book = r.readEntity(Book.class);
+        assertEquals(124L, book.getId());
+        assertEquals("b", r.getHeaderString("a"));
+    }
+    
     @Test
     public void testGetBookSpec() {
         String address = "http://localhost:"; + PORT + 
"/bookstore/bookheaders/simple";

Reply via email to