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 2022/06/26 18:15:26 UTC

[cxf] branch 3.6.x-fixes updated (d59726e6fa -> c122fbdd9e)

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

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


    from d59726e6fa Update Geronimo OpenApi to 1.0.15
     new 840bd0a462 CXF-8725: Optionally don't set (#964)
     new d2ace39315 CXF-8725: Allow RetryStrategy to optionally not retry for 404 responses. Fixing checkstyle violations, minor refactorings and fixes
     new c122fbdd9e Recording .gitmergeinfo Changes

The 3 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                                      |  1 +
 .../java/org/apache/cxf/message/MessageUtils.java  | 23 ++++++++++++++++++++++
 .../org/apache/cxf/message/MessageUtilsTest.java   | 12 ++++++++++-
 .../org/apache/cxf/transport/http/HTTPConduit.java | 20 ++++++++++++++++++-
 4 files changed, 54 insertions(+), 2 deletions(-)


[cxf] 01/03: CXF-8725: Optionally don't set (#964)

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

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

commit 840bd0a46293ceda5c4920678f4eaa7dfacc543a
Author: Konrad Windszus <ko...@gmx.de>
AuthorDate: Sun Jun 26 19:55:58 2022 +0200

    CXF-8725: Optionally don't set (#964)
    
    "org.apache.cxf.transport.service_not_available" for specific HTTP
    response codes
---
 .../java/org/apache/cxf/message/MessageUtils.java    | 20 ++++++++++++++++++++
 .../org/apache/cxf/message/MessageUtilsTest.java     | 12 +++++++++++-
 .../org/apache/cxf/transport/http/HTTPConduit.java   | 13 ++++++++++++-
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/message/MessageUtils.java b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
index e7f75233c5..38d29b5708 100644
--- a/core/src/main/java/org/apache/cxf/message/MessageUtils.java
+++ b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
@@ -21,6 +21,8 @@ package org.apache.cxf.message;
 
 import java.lang.reflect.Method;
 import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Optional;
 import java.util.logging.Logger;
 
@@ -153,6 +155,24 @@ public final class MessageUtils {
         return defaultValue;
     }
 
+    public static Collection<Integer> getContextualIntegers(Message m, String key, Collection<Integer> defaultValue) {
+        if (m != null) {
+            Object o = m.getContextualProperty(key);
+            if (o instanceof String) {
+                Collection<Integer> intValues = new ArrayList<>();
+                for (String value : ((String) o).split(",")) {
+                    try {
+                        intValues.add(Integer.parseInt(value));
+                    } catch (NumberFormatException ex) {
+                        LOG.warning("Incorrect integer value of " + value + " specified for: " + key);
+                    }
+                }
+                return intValues;
+            }
+        }
+        return defaultValue;
+    }
+
     public static int getContextualInteger(Message m, String key, int defaultValue) {
         if (m != null) {
             Object o = m.getContextualProperty(key);
diff --git a/core/src/test/java/org/apache/cxf/message/MessageUtilsTest.java b/core/src/test/java/org/apache/cxf/message/MessageUtilsTest.java
index 298aaa54ab..65a09d8935 100644
--- a/core/src/test/java/org/apache/cxf/message/MessageUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/message/MessageUtilsTest.java
@@ -19,6 +19,7 @@
 package org.apache.cxf.message;
 
 import java.lang.reflect.Method;
+import java.util.List;
 import java.util.Optional;
 
 import javax.xml.namespace.QName;
@@ -29,7 +30,8 @@ import org.apache.cxf.service.factory.SimpleMethodDispatcher;
 import org.apache.cxf.service.invoker.MethodDispatcher;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.OperationInfo;
-
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -80,4 +82,12 @@ public class MessageUtilsTest {
 
         assertFalse(MessageUtils.getTargetMethod(message).isPresent());
     }
+
+    @Test
+    public void getContextualIntegers() {
+        Message message = new MessageImpl();
+        message.put("key1", "1,2,invalid,3");
+        MatcherAssert.assertThat(MessageUtils.getContextualIntegers(message, "key1", List.of(0)), Matchers.contains(1,2,3));
+        MatcherAssert.assertThat(MessageUtils.getContextualIntegers(message, "invalid-key", List.of(0, 1)), Matchers.contains(0,1));
+    }
 }
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index 8db3a3a2e3..cf2517f6a6 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -32,6 +32,7 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -164,6 +165,15 @@ public abstract class HTTPConduit
 
     public static final String PROCESS_FAULT_ON_HTTP_400 = "org.apache.cxf.transport.process_fault_on_http_400";
     public static final String NO_IO_EXCEPTIONS = "org.apache.cxf.transport.no_io_exceptions";
+
+    /** 
+     * The HTTP status codes as contextual property (comma-separated integers as String) on the outgoing {@link Message} which lead to 
+     * setting {@code org.apache.cxf.transport.service_not_available} for all responses with those status codes.
+     * This is used e.g. by the {@code org.apache.cxf.clustering.FailoverTargetSelector} to determine if it should do the fail-over.
+     * Default: {@code 404,429,503} 
+     */
+    public static final String SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES = "org.apache.cxf.transport.service_not_available_on_http_status_codes";
+
     /**
      * The Logger for this class.
      */
@@ -1600,7 +1610,8 @@ public abstract class HTTPConduit
             }
             if (exchange != null) {
                 exchange.put(Message.RESPONSE_CODE, rc);
-                if (rc == 404 || rc == 503 || rc == 429) {
+                Collection<Integer> serviceNotAvailableOnHttpStatusCodes = MessageUtils.getContextualIntegers(outMessage, SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES, List.of(404, 429, 503));
+                if (serviceNotAvailableOnHttpStatusCodes.contains(rc)) {
                     exchange.put("org.apache.cxf.transport.service_not_available", true);
                 }
             }


[cxf] 02/03: CXF-8725: Allow RetryStrategy to optionally not retry for 404 responses. Fixing checkstyle violations, minor refactorings and fixes

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

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

commit d2ace393158045998ba1171c7745d4bdc9147756
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sun Jun 26 14:10:03 2022 -0400

    CXF-8725: Allow RetryStrategy to optionally not retry for 404 responses. Fixing checkstyle violations, minor refactorings and fixes
    
    (cherry picked from commit 7dda93c93d4202eab288328a75d75c8cbc178be1)
---
 .../java/org/apache/cxf/message/MessageUtils.java     |  5 ++++-
 .../org/apache/cxf/transport/http/HTTPConduit.java    | 19 +++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/message/MessageUtils.java b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
index 38d29b5708..755b46b4e6 100644
--- a/core/src/main/java/org/apache/cxf/message/MessageUtils.java
+++ b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
@@ -30,6 +30,7 @@ import org.w3c.dom.Node;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PropertyUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.invoker.MethodDispatcher;
 import org.apache.cxf.service.model.BindingOperationInfo;
 
@@ -162,7 +163,9 @@ public final class MessageUtils {
                 Collection<Integer> intValues = new ArrayList<>();
                 for (String value : ((String) o).split(",")) {
                     try {
-                        intValues.add(Integer.parseInt(value));
+                        if (!StringUtils.isEmpty(value)) {
+                            intValues.add(Integer.parseInt(value.trim()));
+                        }
                     } catch (NumberFormatException ex) {
                         LOG.warning("Incorrect integer value of " + value + " specified for: " + key);
                     }
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index cf2517f6a6..72253c6c4c 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -167,18 +167,23 @@ public abstract class HTTPConduit
     public static final String NO_IO_EXCEPTIONS = "org.apache.cxf.transport.no_io_exceptions";
 
     /** 
-     * The HTTP status codes as contextual property (comma-separated integers as String) on the outgoing {@link Message} which lead to 
-     * setting {@code org.apache.cxf.transport.service_not_available} for all responses with those status codes.
-     * This is used e.g. by the {@code org.apache.cxf.clustering.FailoverTargetSelector} to determine if it should do the fail-over.
-     * Default: {@code 404,429,503} 
+     * The HTTP status codes as contextual property (comma-separated integers as String) 
+     * on the outgoing {@link Message} which lead to setting {@code org.apache.cxf.transport.service_not_available} 
+     * for all responses with those status codes. This is used e.g. by the 
+     * {@code org.apache.cxf.clustering.FailoverTargetSelector} to determine if it should do the fail-over.
+     * Default: {@code 404,429,503} as per {@code DEFAULT_SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES}
      */
-    public static final String SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES = "org.apache.cxf.transport.service_not_available_on_http_status_codes";
+    public static final String SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES = 
+        "org.apache.cxf.transport.service_not_available_on_http_status_codes";
 
     /**
      * The Logger for this class.
      */
     protected static final Logger LOG = LogUtils.getL7dLogger(HTTPConduit.class);
 
+    private static final Collection<Integer> DEFAULT_SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES = 
+            Arrays.asList(404, 429, 503);
+
     private static boolean hasLoggedAsyncWarning;
 
     /**
@@ -1610,7 +1615,9 @@ public abstract class HTTPConduit
             }
             if (exchange != null) {
                 exchange.put(Message.RESPONSE_CODE, rc);
-                Collection<Integer> serviceNotAvailableOnHttpStatusCodes = MessageUtils.getContextualIntegers(outMessage, SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES, List.of(404, 429, 503));
+                final Collection<Integer> serviceNotAvailableOnHttpStatusCodes = MessageUtils
+                    .getContextualIntegers(outMessage, SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES, 
+                        DEFAULT_SERVICE_NOT_AVAILABLE_ON_HTTP_STATUS_CODES);
                 if (serviceNotAvailableOnHttpStatusCodes.contains(rc)) {
                     exchange.put("org.apache.cxf.transport.service_not_available", true);
                 }


[cxf] 03/03: 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 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit c122fbdd9e1923cdb4daaef16f2e0fd65e2498b6
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sun Jun 26 14:11:50 2022 -0400

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

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 2c2b53eaab..944e133267 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -35,6 +35,7 @@ M b15e3580e8f8692b2ffd51e6b2c44ce9dd8a5730
 M b207c718e84bed8120bb114f1d79f575094c3a14
 M c5b7db5a4cceb3df6094ee38215725fd4ecc2b8c
 M ca46bebe06bc2732907e476bfe6116f09fbe1eb4
+M d26294e7f6a011101ec76bc707255899b7539755
 M d4f4b7712b3c8c5c684fa4fa0a28758d9a27cef3
 M d849512da6499d00e3e84eb60733a0343a473b44
 M e4d5c200a8e2b4df6c05c3ac6306e5d6384b81dc