This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new 7dda93c93d CXF-8725: Allow RetryStrategy to optionally not retry for
404 responses. Fixing checkstyle violations, minor refactorings and fixes
7dda93c93d is described below
commit 7dda93c93d4202eab288328a75d75c8cbc178be1
Author: Andriy Redko <[email protected]>
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
---
.../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 3964931530..11d57c66ec 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);
}