Skip to content

Commit

Permalink
NullPointerException: HttpClientPool in org.apache.cxf.Bus using Vert…
Browse files Browse the repository at this point in the history
…xHttpClientHTTPConduitFactory, fix #1579
  • Loading branch information
ppalaga committed Nov 14, 2024
1 parent 2ae227a commit cf28c8c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package io.quarkiverse.cxf.quarkus.vertx.http.client.deployment;

import io.quarkiverse.cxf.deployment.RuntimeBusCustomizerBuildItem;
import io.quarkiverse.cxf.quarkus.vertx.http.client.VertxWebClientRecorder;
import io.quarkiverse.cxf.vertx.http.client.HttpClientPool;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;

public class VertxWebClientProcessor {

Expand All @@ -16,12 +12,4 @@ void additionalBeans(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(HttpClientPool.class));
}

@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void customizers(
VertxWebClientRecorder recorder,
BuildProducer<RuntimeBusCustomizerBuildItem> customizers) {
customizers.produce(new RuntimeBusCustomizerBuildItem(recorder.customizeBus()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ private Object produceCxfClient(CXFClientInfo cxfClientInfo) {
cxfClientInfo,
origConduitImpl,
authorizationPolicy,
vertx);
vertx,
httpClientPool);
props.put(HTTPConduitFactory.class.getName(), conduitFactory);
Object result;
final HTTPConduitFactory origConduitFactory = bus.getExtension(HTTPConduitFactory.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.quarkiverse.cxf;

import java.io.IOException;
import java.util.Objects;

import org.apache.cxf.Bus;
import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transport.http.HTTPTransportFactory;
import org.apache.cxf.transport.http.HttpClientHTTPConduit;
import org.apache.cxf.transport.http.URLConnectionHTTPConduit;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
Expand Down Expand Up @@ -50,10 +48,8 @@ public HTTPConduitImpl resolveDefault() {
@ConfigDocEnumValue("VertxHttpClientHTTPConduitFactory")
VertxHttpClientHTTPConduitFactory {
@Override
public HTTPConduit createConduit(HTTPTransportFactory f, Bus b, EndpointInfo localInfo,
public HTTPConduit createConduit(HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
EndpointReferenceType target) throws IOException {
final HttpClientPool httpClientPool = Objects.requireNonNull(b.getExtension(HttpClientPool.class),
"HttpClientPool in org.apache.cxf.Bus");
return new VertxHttpClientHTTPConduit(b, localInfo, target, httpClientPool);
}

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

@Override
public HTTPConduit createConduit(HTTPTransportFactory f, Bus b, EndpointInfo localInfo, EndpointReferenceType target)
public HTTPConduit createConduit(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 @@ -11,10 +11,10 @@
import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transport.http.HTTPTransportFactory;
import org.apache.cxf.ws.addressing.EndpointReferenceType;

import io.quarkiverse.cxf.CxfClientConfig.WellKnownHostnameVerifier;
import io.quarkiverse.cxf.vertx.http.client.HttpClientPool;
import io.quarkus.tls.TlsConfiguration;
import io.quarkus.tls.runtime.VertxCertificateHolder;
import io.quarkus.tls.runtime.config.TlsBucketConfig;
Expand All @@ -27,7 +27,7 @@ default HTTPConduitSpec resolveDefault() {
return this;
}

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

default Optional<TLSClientParameters> tlsClientParameters(CXFClientInfo cxfClientInfo, Vertx vertx) {
Expand Down Expand Up @@ -115,4 +115,4 @@ default TLSClientParameters createTLSClientParameters(CXFClientInfo cxfClientInf

String getConduitDescription();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.jboss.logging.Logger;

import io.quarkiverse.cxf.vertx.http.client.HttpClientPool;
import io.vertx.core.Vertx;

/**
Expand All @@ -34,19 +35,22 @@ public class QuarkusHTTPConduitFactory implements HTTPConduitFactory {
private final HTTPConduitSpec busHTTPConduitImpl;
private final AuthorizationPolicy authorizationPolicy;
private final Vertx vertx;
private final HttpClientPool httpClientPool;

public QuarkusHTTPConduitFactory(
CxfFixedConfig cxFixedConfig,
CXFClientInfo cxfClientInfo,
HTTPConduitSpec busHTTPConduitImpl,
AuthorizationPolicy authorizationPolicy,
Vertx vertx) {
Vertx vertx,
HttpClientPool httpClientPool) {
super();
this.cxFixedConfig = cxFixedConfig;
this.cxfClientInfo = cxfClientInfo;
this.busHTTPConduitImpl = busHTTPConduitImpl;
this.authorizationPolicy = authorizationPolicy;
this.vertx = vertx;
this.httpClientPool = httpClientPool;
}

@Override
Expand All @@ -59,19 +63,19 @@ public HTTPConduit createConduit(HTTPTransportFactory f, Bus b, EndpointInfo loc
if (httpConduitImpl == null
&& (CXFRecorder.isHc5Present())
&& busHTTPConduitImpl != null) {
return configure(f, busHTTPConduitImpl.resolveDefault(), cxfClientInfo, b, localInfo, target);
return configure(busHTTPConduitImpl.resolveDefault(), cxfClientInfo, b, localInfo, target);
}

if (httpConduitImpl == null) {
httpConduitImpl = HTTPConduitImpl.QuarkusCXFDefault;
}
return configure(f, httpConduitImpl.resolveDefault(), cxfClientInfo, b, localInfo, target);
return configure(httpConduitImpl.resolveDefault(), cxfClientInfo, b, localInfo, target);
}

private HTTPConduit configure(HTTPTransportFactory f, HTTPConduitSpec httpConduitImpl, CXFClientInfo cxfClientInfo, Bus b,
private HTTPConduit configure(HTTPConduitSpec httpConduitImpl, CXFClientInfo cxfClientInfo, Bus b,
EndpointInfo localInfo,
EndpointReferenceType target) throws IOException {
final HTTPConduit httpConduit = httpConduitImpl.createConduit(f, b, localInfo, target);
final HTTPConduit httpConduit = httpConduitImpl.createConduit(httpClientPool, b, localInfo, target);
httpConduitImpl.tlsClientParameters(cxfClientInfo, vertx).ifPresent(httpConduit::setTlsClientParameters);
final HTTPClientPolicy policy = new HTTPClientPolicy();
httpConduit.setClient(policy);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transport.http.HTTPConduitFactory;
import org.apache.cxf.transport.http.HTTPTransportFactory;
import org.apache.cxf.transport.http.asyncclient.hc5.AsyncHTTPConduitFactory;
import org.apache.cxf.transport.http.asyncclient.hc5.AsyncHttpResponseWrapperFactory;
import org.apache.cxf.workqueue.WorkQueueManager;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.eclipse.microprofile.context.ManagedExecutor;

import io.quarkiverse.cxf.HTTPConduitSpec;
import io.quarkiverse.cxf.vertx.http.client.HttpClientPool;
import io.quarkus.arc.Arc;
import io.quarkus.arc.InstanceHandle;
import io.quarkus.runtime.RuntimeValue;
Expand Down Expand Up @@ -48,13 +48,14 @@ public static class Hc5HTTPConduitImpl implements HTTPConduitSpec {
private AsyncHTTPConduitFactory asyncHTTPConduitFactory;

@Override
public HTTPConduit createConduit(HTTPTransportFactory f, Bus b, EndpointInfo localInfo, EndpointReferenceType target)
public HTTPConduit createConduit(HttpClientPool httpClientPool, Bus b, EndpointInfo localInfo,
EndpointReferenceType target)
throws IOException {
AsyncHTTPConduitFactory factory;
if ((factory = asyncHTTPConduitFactory) == null) {
factory = asyncHTTPConduitFactory = new AsyncHTTPConduitFactory(b);
}
return factory.createConduit(f, b, localInfo, target);
return factory.createConduit(b, localInfo, target);
}

@Override
Expand Down

0 comments on commit cf28c8c

Please sign in to comment.