You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2024/11/18 01:52:39 UTC

(cxf) branch 4.0.x-fixes updated (7a3ea8f4ed -> 59734ba809)

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

reta pushed a change to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


    from 7a3ea8f4ed [CXF-9048] Update the WSS4J tests (#2024)
     new 01e0879704 Update Netty to 4.1.115.Final and Netty Tcnative to 2.0.69.Final
     new fe76857bdf Fix flakiness in org.apache.cxf.io.DelayedCachedOutputStreamCleanerTest.testCleanOnShutdown test case
     new d78b7b686e CXF-9076: Exception message is not unmarshalled with JDK17+ (limit the fix to JDK standard library exceptions) (#2148)
     new 59734ba809 Recording .gitmergeinfo Changes

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |  5 ++
 .../cxf/interceptor/ClientFaultConverter.java      | 54 +++++++++++++++-------
 .../io/DelayedCachedOutputStreamCleanerTest.java   |  8 ++--
 distribution/src/main/release/samples/pom.xml      |  2 +-
 parent/pom.xml                                     |  4 +-
 .../systest/jaxws/ClientServerExceptionServer.java |  5 ++
 .../systest/jaxws/ClientServerExceptionTest.java   | 20 ++++++--
 .../apache/cxf/systest/jaxws/ExceptionService.java |  1 +
 .../org/apache/cxf/systest/jaxws/SayException.java | 20 ++++----
 9 files changed, 83 insertions(+), 36 deletions(-)
 copy tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/SuperException.java => systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SayException.java (74%)


(cxf) 03/04: CXF-9076: Exception message is not unmarshalled with JDK17+ (limit the fix to JDK standard library exceptions) (#2148)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d78b7b686ee03fba361099472bfde787cc33a9ed
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sun Nov 17 11:39:54 2024 -0500

    CXF-9076: Exception message is not unmarshalled with JDK17+ (limit the fix to JDK standard library exceptions) (#2148)
    
    (cherry picked from commit e6229afc8c15fe46b2c64116e76fea794af03f98)
---
 .../cxf/interceptor/ClientFaultConverter.java      | 54 +++++++++++++++-------
 .../systest/jaxws/ClientServerExceptionServer.java |  5 ++
 .../systest/jaxws/ClientServerExceptionTest.java   | 20 ++++++--
 .../apache/cxf/systest/jaxws/ExceptionService.java |  1 +
 .../{ExceptionService.java => SayException.java}   | 19 ++++++--
 5 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java b/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
index c2c1f9c365..c270f4d920 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
@@ -200,21 +200,8 @@ public class ClientFaultConverter extends AbstractInDatabindingInterceptor {
                     ReflectionUtil.setAccessible(f);
                     f.set(ex, fault.getMessage());
                 } catch (Exception e1) {
-                    try {
-                        // Fallback, try to clone the exception instead of accessing the detailMessage over reflection
-                        final Constructor<? extends Object> constructor = ReflectionUtil.getConstructor(ex.getClass(),
-                            String.class, Throwable.class); /* String message, Throwable cause */
-
-                        if (constructor != null) {
-                            final Exception clone = (Exception) constructor.newInstance(message, ex.getCause());
-                            clone.setStackTrace(ex.getStackTrace());
-                            if (ex.getSuppressed().length > 0) {
-                                Arrays.stream(ex.getSuppressed()).forEach(clone::addSuppressed);
-                            }
-                            ex = clone;
-                        }
-                    } catch (Exception e2) {
-                        /* nothing to do */
+                    if (isJdkException(ex.getClass().getPackageName())) {
+                        ex = cloneJdkException(ex, message);
                     }
                 }
             }
@@ -222,6 +209,37 @@ public class ClientFaultConverter extends AbstractInDatabindingInterceptor {
         }
     }
 
+    private static Exception cloneJdkException(Exception ex, final String message) {
+        try {
+            // Fallback, try to clone the exception instead of accessing the detailMessage 
+            // over reflection
+            Constructor<? extends Object> constructor = ReflectionUtil.getConstructor(
+                ex.getClass(), String.class, Throwable.class); /* String message, Throwable cause */
+   
+            Exception clone = null;
+            if (constructor != null) {
+                clone = (Exception) constructor.newInstance(message, ex.getCause());
+            } else {
+                constructor = ReflectionUtil.getConstructor(ex.getClass(), String.class); /* String message */
+                if (constructor != null) {
+                    clone = (Exception) constructor.newInstance(message);
+                    clone.initCause(ex.getCause());
+                }
+            }
+
+            if (clone != null) {
+                clone.setStackTrace(ex.getStackTrace());
+                if (ex.getSuppressed().length > 0) {
+                    Arrays.stream(ex.getSuppressed()).forEach(clone::addSuppressed);
+                }
+                return clone;
+            }
+        } catch (Exception e2) {
+            /* nothing to do */
+        }
+        return ex;
+    }
+
     private Constructor<?> getConstructor(Class<?> faultClass, Object e) throws NoSuchMethodException {
         Class<?> beanClass = e.getClass();
         Constructor<?>[] cons = faultClass.getConstructors();
@@ -300,7 +318,7 @@ public class ClientFaultConverter extends AbstractInDatabindingInterceptor {
         Throwable res = null;
         if (firstLine.indexOf(':') != -1) {
             String cn = firstLine.substring(0, firstLine.indexOf(':')).trim();
-            if (cn.startsWith("java.lang")) {
+            if (isJdkException(cn)) {
                 try {
                     res = (Throwable)Class.forName(cn).getConstructor(String.class)
                             .newInstance(firstLine.substring(firstLine.indexOf(':') + 2));
@@ -327,6 +345,10 @@ public class ClientFaultConverter extends AbstractInDatabindingInterceptor {
         return res;
     }
 
+    private static boolean isJdkException(String pkg) {
+        return pkg.startsWith("java.lang");
+    }
+
     private static StackTraceElement parseStackTrackLine(String oneLine) {
         StringTokenizer stInner = new StringTokenizer(oneLine, "!");
         return new StackTraceElement(stInner.nextToken(), stInner.nextToken(),
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionServer.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionServer.java
index 06ad7e98f0..2cb2d371a6 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionServer.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionServer.java
@@ -33,6 +33,11 @@ public class ClientServerExceptionServer extends AbstractBusTestServerBase {
         public String saySomething(String text) throws IllegalArgumentException {
             throw new IllegalArgumentException("Simulated!");
         }
+
+        @Override
+        public String sayNothing(String text) throws SayException {
+            throw new SayException("Simulated!", 100);
+        }
     }
 
     protected void run() {
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionTest.java
index 2e74489026..73db4fcc54 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerExceptionTest.java
@@ -27,6 +27,7 @@ import javax.xml.namespace.QName;
 import jakarta.xml.ws.Service;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -35,20 +36,33 @@ import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
 public class ClientServerExceptionTest extends AbstractBusClientServerTestBase {
+    private ExceptionService port;
+
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", launchServer(ClientServerExceptionServer.class, true));
     }
 
-    @Test
-    public void exceptionMessageIsPreserved() throws MalformedURLException {
+    @Before
+    public void setUp() throws Exception {
         URL wsdlURL = new URL("http://localhost:" + ClientServerExceptionServer.PORT + "/ExceptionService?wsdl");
         QName qname = new QName("http://cxf.apache.org/", "ExceptionService");
         Service service = Service.create(wsdlURL, qname);
-        ExceptionService port = service.getPort(ExceptionService.class);
+        port = service.getPort(ExceptionService.class);
+    }
 
+    @Test
+    public void exceptionMessageIsPreserved() throws MalformedURLException {
         final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
             () -> port.saySomething("Hello World!"));
         assertEquals("Simulated!", ex.getMessage());
     }
+
+    @Test
+    public void exceptionCustomExceptionMessageIsPreserved() throws MalformedURLException {
+        final SayException ex = assertThrows(SayException.class,
+            () -> port.sayNothing("Hello World!"));
+        assertEquals("Simulated!", ex.getMessage());
+        assertEquals(100, ex.getCode());
+    }
 }
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java
index ac2d87083f..6473b80972 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java
@@ -24,4 +24,5 @@ import jakarta.jws.WebService;
 @WebService
 interface ExceptionService {
     String saySomething(String text) throws IllegalArgumentException;
+    String sayNothing(String text) throws SayException;
 }
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SayException.java
similarity index 70%
copy from systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java
copy to systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SayException.java
index ac2d87083f..0201400b0e 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ExceptionService.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SayException.java
@@ -19,9 +19,20 @@
 
 package org.apache.cxf.systest.jaxws;
 
-import jakarta.jws.WebService;
+public class SayException extends Exception {
+    private static final long serialVersionUID = 1L;
+    private final int code;
 
-@WebService
-interface ExceptionService {
-    String saySomething(String text) throws IllegalArgumentException;
+    public SayException() {
+        this(null, 0);
+    }
+
+    public SayException(final String message, final int code) {
+        super(message);
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
 }


(cxf) 01/04: Update Netty to 4.1.115.Final and Netty Tcnative to 2.0.69.Final

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 01e087970402d284e217ce1be674a00eab774c70
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Thu Nov 14 13:26:13 2024 -0500

    Update Netty to 4.1.115.Final and Netty Tcnative to 2.0.69.Final
    
    (cherry picked from commit ce13e155bcdf28611177a35f4d29e4967cc07828)
    
    # Conflicts:
    #       distribution/src/main/release/samples/pom.xml
---
 distribution/src/main/release/samples/pom.xml | 2 +-
 parent/pom.xml                                | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/distribution/src/main/release/samples/pom.xml b/distribution/src/main/release/samples/pom.xml
index 901e0e09cd..6577aceeb6 100644
--- a/distribution/src/main/release/samples/pom.xml
+++ b/distribution/src/main/release/samples/pom.xml
@@ -34,7 +34,7 @@
         <cxf.spring.boot.version>3.0.13</cxf.spring.boot.version>
         <cxf.spring.cloud.eureka.version>4.0.3</cxf.spring.cloud.eureka.version>
         <cxf.jetty11.version>11.0.24</cxf.jetty11.version>
-        <cxf.netty.version>4.1.114.Final</cxf.netty.version>
+        <cxf.netty.version>4.1.115.Final</cxf.netty.version>
         <cxf.httpcomponents.client.version>4.5.14</cxf.httpcomponents.client.version>
         <cxf.swagger.ui.version>5.18.2</cxf.swagger.ui.version>
         <cxf.tika.version>2.9.1</cxf.tika.version>
diff --git a/parent/pom.xml b/parent/pom.xml
index 41a9fa8d06..e5f13cd736 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -187,8 +187,8 @@
         <cxf.msv.version>2022.7</cxf.msv.version>
         <cxf.neethi.version>3.2.1</cxf.neethi.version>
         <cxf.netty.version.range>[4,5)</cxf.netty.version.range>
-        <cxf.netty.version>4.1.114.Final</cxf.netty.version>
-        <cxf.netty.tcnative.version>2.0.46.Final</cxf.netty.tcnative.version>
+        <cxf.netty.version>4.1.115.Final</cxf.netty.version>
+        <cxf.netty.tcnative.version>2.0.69.Final</cxf.netty.tcnative.version>
         <cxf.olingo.version>2.0.12</cxf.olingo.version>
         <cxf.openjpa.version>3.2.2</cxf.openjpa.version>
         <cxf.opentelemetry.version>1.34.1</cxf.opentelemetry.version>


(cxf) 04/04: Recording .gitmergeinfo Changes

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 59734ba809fb6422a6b5dc9917ee428797aa7ef5
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sun Nov 17 18:10:15 2024 -0500

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index e14f721e8e..15d1555f71 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -22,6 +22,7 @@ M 138ea01e28f86fe29bb004efcf1a0e26c1752b76
 M 159f0e1eb48d9f185c41b748feb5da92d1d04dcb
 M 17d5f097db56b068a73bad99ca210a3c063b0b7a
 M 18c8d17917ca884b7c8e4e1b20591ced2366ca38
+M 1a194eab65dad8347bb2856fdf62fa3e16d4e251
 M 1a26597eece270dac44750f7e279bc343789e331
 M 1a2e6f2abe74c6fa5589a183e918604ee950851c
 M 1aa37ee19b69b96d4d4dd0313f9ea48b130ac586
@@ -59,6 +60,7 @@ M 3901f921ca83dd2ba9e191a01b63fe85fef1baaa
 M 399a5e8bd55d1e98cf236058a6cff9b41560c64e
 M 39f98b2685b0088f9be5dbb55777e92e10ab7a35
 M 3a6c3e8667160a78ad094779e631deba46c0b8be
+M 3bbdbb7614fd5e196ffba42f68b8122ba3c24e25
 M 3bceb74bb469657b283995162aa7634070cd54d1
 M 3e9348f48df34adc5600d2197edfc41f2c9dc981
 M 3f8e439fc58d00e3fd342a243d6ad6a0c7b3c32e
@@ -80,6 +82,7 @@ M 4be33dce0cad5353a094fe08aba49989b93eb99b
 M 4f16fb986dadbc87d53d13fb17a23b8c95ad5ac3
 M 50058598b0caddc83b4a23b2454af25d1c23a76e
 M 50f42fc67bc129c9a44e0546e626a392b6138835
+M 5251e3b7aab69bc106e7b822557d4e2f36ba212a
 M 53c936caf3192c392287539ef5129755fee0225d
 M 54bdaca5fc884d107c4e56f7a762a1ec8b165695
 M 54c3ce63ef139f99c12f2290b2107c2f428fba51
@@ -120,6 +123,7 @@ M 79fd113bae51d0e9bf0300f1e79a9c6add5d3563
 M 7a20ba731f51919688e5c1f0e7d9614fb10b1cb9
 M 7a54bd969f6ceedd4d0933e51df3eb68b44a1a16
 M 7ab74899002f69055175dacae946b7664413c9ad
+M 7bf082db5cc1334f6873c7578a921b822ecaaafe
 M 7c03050adef2195f23826beb6768f25e29b2b1f5
 M 7c4b82edbbbe2589ac098991d096183718cff929
 M 7cdfacdb8840c440cedc23b26e2a15f5d544e9eb
@@ -201,6 +205,7 @@ M cbb76ba80791779b3bdc163c0762812947181f97
 M cc06da466dfe5f6293843f677b961c03dee997fb
 M cd53e4953d90fed16cd99d131b905cefcd748935
 M cdaac75da63f45e336b4e144a34c7c8bca9ba03d
+M ce13e155bcdf28611177a35f4d29e4967cc07828
 M d1b00ae6b906c7511a176e50775e97a7d9f043cc
 M d1e7f67d939da5368bc83b1212b5a08d33d8c9bf
 M d561796d14982c46452d15ed78b6a0892bdb2a18


(cxf) 02/04: Fix flakiness in org.apache.cxf.io.DelayedCachedOutputStreamCleanerTest.testCleanOnShutdown test case

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fe76857bdfa7d2dd39345b1f1e1aa73dea652de6
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Nov 16 12:22:57 2024 -0500

    Fix flakiness in org.apache.cxf.io.DelayedCachedOutputStreamCleanerTest.testCleanOnShutdown test case
    
    (cherry picked from commit 3ff5a8f32a51f1de48bb3c5e724db68dae66a68a)
---
 .../org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java   | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java b/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java
index 8fcb12cf46..1cd557c1c6 100644
--- a/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java
+++ b/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java
@@ -147,14 +147,13 @@ public class DelayedCachedOutputStreamCleanerTest {
     
     @Test
     public void testCleanOnShutdown() throws InterruptedException {
-        /* Delay of 2.5 seconds */
-        final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500);
+        /* Delay of 5 seconds */
+        final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 5000);
         bus = new ExtensionManagerBus(new HashMap<>(), properties);
 
         final AtomicBoolean latch = new AtomicBoolean();
         final Closeable closeable = () -> latch.compareAndSet(false, true);
 
-        bus.setProperty(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500); /* 2.5 seconds */
         final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
         cleaner.register(closeable);
 
@@ -169,14 +168,13 @@ public class DelayedCachedOutputStreamCleanerTest {
     public void testCleanOnShutdownDisabled() throws InterruptedException {
         /* Delay of 2.5 seconds */
         final Map<String, Object> properties = new HashMap<>();
-        properties.put(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500);
+        properties.put(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500); /* 2.5 seconds */
         properties.put(CachedConstants.CLEANER_CLEAN_ON_SHUTDOWN_BUS_PROP, false);
         bus = new ExtensionManagerBus(new HashMap<>(), properties);
 
         final AtomicBoolean latch = new AtomicBoolean();
         final Closeable closeable = () -> latch.compareAndSet(false, true);
 
-        bus.setProperty(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500); /* 2.5 seconds */
         final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
         cleaner.register(closeable);