Skip to content

Commit

Permalink
Add quarkus.cxf.client."client-name".max-same-uri configuration option,
Browse files Browse the repository at this point in the history
fix #1639
  • Loading branch information
ppalaga committed Dec 20, 2024
1 parent 66dc7ba commit a11dc7e
Show file tree
Hide file tree
Showing 14 changed files with 353 additions and 133 deletions.
33 changes: 27 additions & 6 deletions docs/modules/ROOT/examples/client-server/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,33 @@ quarkus.cxf.client.doubleRedirectMaxRetransmits2.redirect-relative-uri = true
quarkus.cxf.client.doubleRedirectMaxRetransmits2.max-retransmits = 2
quarkus.cxf.client.doubleRedirectMaxRetransmits2.auto-redirect = true

quarkus.cxf.client.selfRedirect.client-endpoint-url = http://localhost:${quarkus.http.test-port}/RedirectRest/selfRedirect
quarkus.cxf.client.selfRedirect.service-interface = io.quarkiverse.cxf.it.large.slow.generated.LargeSlowService
quarkus.cxf.client.selfRedirect.redirect-relative-uri = true
quarkus.cxf.client.selfRedirect.max-retransmits = 4
quarkus.cxf.client.selfRedirect.max-same-uri = 3
quarkus.cxf.client.selfRedirect.auto-redirect = true
quarkus.cxf.client.doubleRedirectMaxRetransmits2MaxSameUri0.client-endpoint-url = http://localhost:${quarkus.http.test-port}/RedirectRest/doubleRedirect
quarkus.cxf.client.doubleRedirectMaxRetransmits2MaxSameUri0.service-interface = io.quarkiverse.cxf.it.large.slow.generated.LargeSlowService
quarkus.cxf.client.doubleRedirectMaxRetransmits2MaxSameUri0.redirect-relative-uri = true
quarkus.cxf.client.doubleRedirectMaxRetransmits2MaxSameUri0.max-retransmits = 2
quarkus.cxf.client.doubleRedirectMaxRetransmits2MaxSameUri0.auto-redirect = true
quarkus.cxf.client.doubleRedirectMaxRetransmits2MaxSameUri0.max-same-uri = 0

quarkus.cxf.client.maxSameUri1.client-endpoint-url = http://localhost:${quarkus.http.test-port}/RedirectRest/selfRedirect/1/2
quarkus.cxf.client.maxSameUri1.service-interface = io.quarkiverse.cxf.it.large.slow.generated.LargeSlowService
quarkus.cxf.client.maxSameUri1.redirect-relative-uri = true
quarkus.cxf.client.maxSameUri1.max-retransmits = 4
quarkus.cxf.client.maxSameUri1.max-same-uri = 1
quarkus.cxf.client.maxSameUri1.auto-redirect = true

quarkus.cxf.client.maxSameUri2.client-endpoint-url = http://localhost:${quarkus.http.test-port}/RedirectRest/selfRedirect/2/2
quarkus.cxf.client.maxSameUri2.service-interface = io.quarkiverse.cxf.it.large.slow.generated.LargeSlowService
quarkus.cxf.client.maxSameUri2.redirect-relative-uri = true
quarkus.cxf.client.maxSameUri2.max-retransmits = 4
quarkus.cxf.client.maxSameUri2.max-same-uri = 2
quarkus.cxf.client.maxSameUri2.auto-redirect = true

quarkus.cxf.client.maxSameUri3.client-endpoint-url = http://localhost:${quarkus.http.test-port}/RedirectRest/selfRedirect/3/4
quarkus.cxf.client.maxSameUri3.service-interface = io.quarkiverse.cxf.it.large.slow.generated.LargeSlowService
quarkus.cxf.client.maxSameUri3.redirect-relative-uri = true
quarkus.cxf.client.maxSameUri3.max-retransmits = 4
quarkus.cxf.client.maxSameUri3.max-same-uri = 3
quarkus.cxf.client.maxSameUri3.auto-redirect = true

quarkus.cxf.client.loop.client-endpoint-url = http://localhost:${quarkus.http.test-port}/RedirectRest/loop1
quarkus.cxf.client.loop.service-interface = io.quarkiverse.cxf.it.large.slow.generated.LargeSlowService
Expand Down
21 changes: 10 additions & 11 deletions docs/modules/ROOT/pages/reference/extensions/quarkus-cxf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1696,14 +1696,15 @@ See also:
.<| `int`
.<| `-1`

3+a|Specifies the maximum amount of retransmits that are allowed for redirects. Retransmits for authorization is included in
the retransmit count. Each redirect may cause another retransmit for a UNAUTHORIZED response code, ie. 401. Any negative
number indicates unlimited retransmits, although, loop protection is provided. The default is unlimited. (name is not
part of standard)
3+a|Specifies the maximum allowed number of retransmits when following redirects.
Retransmits for authorization are included in the retransmit count.
Each 401 UNAUTHORIZED response may cause a new retransmit.
A negative value indicates unlimited retransmits, but even in that case redirect loop protection is provided.

See also:

* `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-auto-redirect[quarkus.cxf.client."client-name".auto-redirect]`
* `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-max-same-uri[quarkus.cxf.client."client-name".max-same-uri]`

*Environment variable*: `+++QUARKUS_CXF_CLIENT__CLIENT_NAME__MAX_RETRANSMITS+++` +
*Since Quarkus CXF*: 2.2.3
Expand All @@ -1712,18 +1713,16 @@ See also:
.<| `int`
.<| `0`

3+a|Specifies the maximum amount of retransmits to the same uri that are allowed for redirects. Retransmits for authorization
is included in the retransmit count. Each redirect may cause another retransmit for a UNAUTHORIZED response code, ie.
401. Any negative number indicates unlimited retransmits, although, loop protection is provided. The default is
unlimited. (name is not part of standard)
3+a|Specifies the maximum allowed number of retransmits to the same URI when following HTTP redirects.
The default behavior is to allow a no retransmits to the same URI.

See also:

*
`xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-auto-redirect[quarkus.cxf.client."client-name".auto-redirect]`
* `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-auto-redirect[quarkus.cxf.client."client-name".auto-redirect]`
* `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-max-retransmits[quarkus.cxf.client."client-name".max-retransmits]`

*Environment variable*: `+++QUARKUS_CXF_CLIENT__CLIENT_NAME__MAX_SAME_URI+++` +
*Since Quarkus CXF*: 3.17.4
*Since Quarkus CXF*: 3.18.0

.<| [[quarkus-cxf_quarkus-cxf-client-client-name-allow-chunking]]`link:#quarkus-cxf_quarkus-cxf-client-client-name-allow-chunking[quarkus.cxf.client."client-name".allow-chunking]`
.<| `boolean`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package io.quarkiverse.cxf;

import java.security.KeyStore;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;

import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.transports.http.configuration.ConnectionType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,15 @@ public interface CxfClientConfig {
// The formatter breaks the list with long items
// @formatter:off
/**
* Specifies the maximum amount of retransmits that are allowed for redirects. Retransmits for authorization is included in
* the retransmit count. Each redirect may cause another retransmit for a UNAUTHORIZED response code, ie. 401. Any negative
* number indicates unlimited retransmits, although, loop protection is provided. The default is unlimited. (name is not
* part of standard)
* Specifies the maximum allowed number of retransmits when following redirects.
* Retransmits for authorization are included in the retransmit count.
* Each 401 UNAUTHORIZED response may cause a new retransmit.
* A negative value indicates unlimited retransmits, but even in that case redirect loop protection is provided.
*
* See also:
*
* * `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-auto-redirect[quarkus.cxf.client."client-name".auto-redirect]`
* * `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-max-same-uri[quarkus.cxf.client."client-name".max-same-uri]`
*
* @since 2.2.3
* @asciidoclet
Expand All @@ -249,20 +250,21 @@ public interface CxfClientConfig {
@WithDefault("-1")
public int maxRetransmits();

// The formatter breaks the list with long items
// @formatter:off
/**
* Specifies the maximum amount of retransmits to the same uri that are allowed for redirects. Retransmits for authorization
* is included in the retransmit count. Each redirect may cause another retransmit for a UNAUTHORIZED response code, ie.
* 401. Any negative number indicates unlimited retransmits, although, loop protection is provided. The default is
* unlimited. (name is not part of standard)
* Specifies the maximum allowed number of retransmits to the same URI when following HTTP redirects.
* The default behavior is to allow a no retransmits to the same URI.
*
* See also:
*
* *
* `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-auto-redirect[quarkus.cxf.client."client-name".auto-redirect]`
* * `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-auto-redirect[quarkus.cxf.client."client-name".auto-redirect]`
* * `xref:reference/extensions/quarkus-cxf.adoc#quarkus-cxf_quarkus-cxf-client-client-name-max-retransmits[quarkus.cxf.client."client-name".max-retransmits]`
*
* @since 3.17.4
* @since 3.18.0
* @asciidoclet
*/
// @formatter:on
@WithDefault("0")
public int maxSameUri();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ private Object produceCxfClient(CXFClientInfo cxfClientInfo) {
}
{
final int value = cxfClientInfo.getMaxSameUri();
props.put(VertxHttpClientHTTPConduit.AUTO_REDIRECT_MAX_SAME_URI_COUNT, value);
if (value > 0) {
/* 0 is the deafult that makes no difference in the handling so we can ignore it here */
props.put(VertxHttpClientHTTPConduit.AUTO_REDIRECT_MAX_SAME_URI_COUNT, value);
}
}

loggingFactoryCustomizer.customize(cxfClientInfo, factory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public HTTPConduitImpl resolveDefault() {
@ConfigDocEnumValue("VertxHttpClientHTTPConduitFactory")
VertxHttpClientHTTPConduitFactory {
@Override
public HTTPConduit createConduit(HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
public HTTPConduit createConduit(String configKey, HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
EndpointReferenceType target) throws IOException {
return new VertxHttpClientHTTPConduit(b, localInfo, target, httpClientPool);
return new VertxHttpClientHTTPConduit(configKey, b, localInfo, target, httpClientPool);
}

@Override
Expand All @@ -71,15 +71,15 @@ public TLSClientParameters createTLSClientParameters(CXFClientInfo cxfClientInfo
@ConfigDocEnumValue("HttpClientHTTPConduitFactory")
HttpClientHTTPConduitFactory {
@Override
public HTTPConduit createConduit(HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
public HTTPConduit createConduit(String configKey, HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
EndpointReferenceType target) throws IOException {
return new HttpClientHTTPConduit(b, localInfo, target);
}
},
@ConfigDocEnumValue("URLConnectionHTTPConduitFactory")
URLConnectionHTTPConduitFactory {
@Override
public HTTPConduit createConduit(HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
public HTTPConduit createConduit(String configKey, HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
EndpointReferenceType target) throws IOException {
return new URLConnectionHTTPConduit(b, localInfo, target);
}
Expand All @@ -96,7 +96,8 @@ public static HTTPConduitImpl findDefaultHTTPConduitImpl() {
}

@Override
public HTTPConduit createConduit(HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo, EndpointReferenceType target)
public HTTPConduit createConduit(String configKey, HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
EndpointReferenceType target)
throws IOException {
throw new IllegalStateException(
"Call " + HTTPConduitImpl.class.getName() + ".resolveDefault() before calling createConduit()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ default HTTPConduitSpec resolveDefault() {
return this;
}

HTTPConduit createConduit(HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo, EndpointReferenceType target)
HTTPConduit createConduit(String configKey, HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
EndpointReferenceType target)
throws IOException;

default Optional<TLSClientParameters> tlsClientParameters(CXFClientInfo cxfClientInfo, Vertx vertx) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.quarkiverse.cxf;

import io.smallrye.config.NameIterator;

public class QuarkusCxfUtils {
private QuarkusCxfUtils() {
}

/**
* Keys occurring in free form configuration maps may need quoting with double quotes, if they contain periods.
*
* @param key a key occurring in a free form configuration map, such as {@code "client-name"} in
* {@code quarkus.cxf.client."client-name".logging.enabled}.
* @return a possibly quoted key
*/
public static String quoteCongurationKeyIfNeeded(String key) {
final NameIterator keyIterator = new NameIterator(key);
keyIterator.next();
return keyIterator.hasNext() ? "\"" + key + "\"" : key;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public HTTPConduit createConduit(HTTPTransportFactory f, Bus b, EndpointInfo loc
private HTTPConduit configure(HTTPConduitSpec httpConduitImpl, CXFClientInfo cxfClientInfo, Bus b,
EndpointInfo localInfo,
EndpointReferenceType target) throws IOException {
final HTTPConduit httpConduit = httpConduitImpl.createConduit(httpClientPool, b, localInfo, target);
final HTTPConduit httpConduit = httpConduitImpl.createConduit(
cxfClientInfo.getConfigKey(),
httpClientPool,
b,
localInfo,
target);
if (httpConduit instanceof HttpClientHTTPConduit) {
Log.warnf("Usage of %s is deprecated since Quarkus CXF 3.18.0."
+ " You may want to review the options quarkus.cxf.http-conduit-factory and/or quarkus.cxf.client.\"%s\".http-conduit-factory",
Expand Down
Loading

0 comments on commit a11dc7e

Please sign in to comment.