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 <[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 (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); }
