diff --git a/clients/java/client/pom.xml b/clients/java/client/pom.xml index 2defee0ed3d..190b3913b59 100644 --- a/clients/java/client/pom.xml +++ b/clients/java/client/pom.xml @@ -14,7 +14,6 @@ - 5.3 ${project.build.directory}/camunda-tomcat ${engine.runtime}/server/apache-tomcat-${version.tomcat} ${tomcat.connector.http.port} diff --git a/connect/README.md b/connect/README.md index d60b02f0e3f..5817b5f50a5 100644 --- a/connect/README.md +++ b/connect/README.md @@ -2,7 +2,7 @@ camunda-connect ===============

- Home | + Home | Documentation | Forum | Issues | @@ -12,14 +12,14 @@ camunda-connect Simple API for connecting HTTP Services and other things. -# List of connectors +# List of Connectors -* HTTP Connector -* SOAP HTTP Connector +* HTTP Connector (using Apache HttpClient 5.x) +* SOAP HTTP Connector (using Apache HttpClient 5.x) # Using a Connector -camunda Connect API aims at two usage scenarios, usage in a generic system such as Camunda Platform +Camunda Connect API aims at two usage scenarios, usage in a generic system such as Camunda Platform process engine and standalone usage via API. Please see the [official documentation](https://docs.camunda.org/manual/latest/reference/connect/) for more information. # Contributing @@ -27,10 +27,6 @@ process engine and standalone usage via API. Please see the [official documentat Have a look at our [contribution guide](https://github.com/camunda/camunda-bpm-platform/blob/master/CONTRIBUTING.md) for how to contribute to this repository. -# License: +# License The source files in this repository are made available under the Apache License, Version 2.0. - - - -[CONTRIBUTING.md]: https://github.com/camunda/camunda-bpm-platform/blob/master/CONTRIBUTING.md diff --git a/connect/core/src/main/java/org/camunda/connect/Connectors.java b/connect/core/src/main/java/org/camunda/connect/Connectors.java index e458fca7907..ace6e872954 100644 --- a/connect/core/src/main/java/org/camunda/connect/Connectors.java +++ b/connect/core/src/main/java/org/camunda/connect/Connectors.java @@ -40,7 +40,7 @@ public class Connectors { public static String SOAP_HTTP_CONNECTOR_ID = "soap-http-connector"; /** The global instance of the manager */ - static Connectors INSTANCE = new Connectors(); + static final Connectors INSTANCE = new Connectors(); /** * Provides the global instance of the Connectors manager. @@ -54,27 +54,24 @@ public static Connectors getInstance() { * @return the connector for the default http connector id or null if * no connector is registered for this id */ - @SuppressWarnings("unchecked") public static >> C http() { - return (C) INSTANCE.getConnectorById(HTTP_CONNECTOR_ID); + return getConnector(HTTP_CONNECTOR_ID); } /** * @return the connector for the default soap http connector id or null * if no connector is registered for this id */ - @SuppressWarnings("unchecked") public static >> C soap() { - return (C) INSTANCE.getConnectorById(SOAP_HTTP_CONNECTOR_ID); + return getConnector(SOAP_HTTP_CONNECTOR_ID); } /** * @return the connector for the given id or null if no connector is * registered for this id */ - @SuppressWarnings("unchecked") public static >> C getConnector(String connectorId) { - return (C) INSTANCE.getConnectorById(connectorId); + return INSTANCE.getConnectorById(connectorId); } /** @@ -126,7 +123,7 @@ protected static void unregisterConnector(String connectorId) { */ public Set>> getAllAvailableConnectors() { ensureConnectorProvidersInitialized(); - return new HashSet>(availableConnectors.values()); + return new HashSet<>(availableConnectors.values()); } /** @@ -153,9 +150,9 @@ protected void ensureConnectorProvidersInitialized() { } protected void initializeConnectors(ClassLoader classLoader) { - Map> connectors = new HashMap>(); + Map> connectors = new HashMap<>(); - if(classLoader == null) { + if (classLoader == null) { classLoader = Connectors.class.getClassLoader(); } @@ -181,8 +178,7 @@ protected void registerProvider(Map> connectors, ConnectorP String connectorId = provider.getConnectorId(); if (connectors.containsKey(connectorId)) { throw LOG.multipleConnectorProvidersFound(connectorId); - } - else { + } else { Connector connectorInstance = provider.createConnectorInstance(); LOG.connectorProviderDiscovered(provider, connectorId, connectorInstance); connectors.put(connectorId, connectorInstance); diff --git a/connect/core/src/main/java/org/camunda/connect/impl/AbstractCloseableConnectorResponse.java b/connect/core/src/main/java/org/camunda/connect/impl/AbstractCloseableConnectorResponse.java index 63824151496..8ae804db344 100644 --- a/connect/core/src/main/java/org/camunda/connect/impl/AbstractCloseableConnectorResponse.java +++ b/connect/core/src/main/java/org/camunda/connect/impl/AbstractCloseableConnectorResponse.java @@ -30,7 +30,7 @@ */ public abstract class AbstractCloseableConnectorResponse extends AbstractConnectorResponse implements CloseableConnectorResponse { - private final static ConnectCoreLogger LOG = ConnectLogger.CORE_LOGGER; + private static final ConnectCoreLogger LOG = ConnectLogger.CORE_LOGGER; /** * Implements the default close behavior diff --git a/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnector.java b/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnector.java index 920e8693c77..6db4d7ae403 100644 --- a/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnector.java +++ b/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnector.java @@ -22,12 +22,11 @@ import org.camunda.connect.spi.Connector; import org.camunda.connect.spi.ConnectorRequest; -import org.camunda.connect.spi.ConnectorResponse; import org.camunda.connect.spi.ConnectorRequestInterceptor; +import org.camunda.connect.spi.ConnectorResponse; /** * Abstract implementation of the connector interface. - * * This implementation provides a linked list of interceptors and related methods for * handling interceptor invocation. * @@ -41,9 +40,9 @@ public abstract class AbstractConnector, R extends /** * The {@link ConnectorRequestInterceptor} chain */ - protected List requestInterceptors = new LinkedList(); + protected List requestInterceptors = new LinkedList<>(); - public AbstractConnector(String connectorId) { + protected AbstractConnector(String connectorId) { this.connectorId = connectorId; } diff --git a/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorRequest.java b/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorRequest.java index ccbd6e288b4..0a67ed22d30 100644 --- a/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorRequest.java +++ b/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorRequest.java @@ -32,15 +32,15 @@ public abstract class AbstractConnectorRequest impl protected Connector connector; - protected Map requestParameters = new HashMap(); + protected Map requestParameters = new HashMap<>(); - public AbstractConnectorRequest(Connector connector) { + protected AbstractConnectorRequest(Connector connector) { this.connector = connector; } @SuppressWarnings("unchecked") public R execute() { - if(!isRequestValid()) { + if (!isRequestValid()) { throw new RuntimeException("The request is invalid"); } return (R) connector.execute(this); diff --git a/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorResponse.java b/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorResponse.java index 7171a8beccd..77ee308a797 100644 --- a/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorResponse.java +++ b/connect/core/src/main/java/org/camunda/connect/impl/AbstractConnectorResponse.java @@ -30,8 +30,8 @@ public abstract class AbstractConnectorResponse implements ConnectorResponse { protected Map responseParameters; public Map getResponseParameters() { - if(responseParameters == null) { - responseParameters = new HashMap(); + if (responseParameters == null) { + responseParameters = new HashMap<>(); collectResponseParameters(responseParameters); } return responseParameters; diff --git a/connect/core/src/main/java/org/camunda/connect/impl/AbstractRequestInvocation.java b/connect/core/src/main/java/org/camunda/connect/impl/AbstractRequestInvocation.java index 215ccdc2154..10bfabea81e 100644 --- a/connect/core/src/main/java/org/camunda/connect/impl/AbstractRequestInvocation.java +++ b/connect/core/src/main/java/org/camunda/connect/impl/AbstractRequestInvocation.java @@ -18,8 +18,8 @@ import java.util.List; -import org.camunda.connect.spi.ConnectorRequest; import org.camunda.connect.spi.ConnectorInvocation; +import org.camunda.connect.spi.ConnectorRequest; import org.camunda.connect.spi.ConnectorRequestInterceptor; /** @@ -40,7 +40,7 @@ public abstract class AbstractRequestInvocation implements ConnectorInvocatio protected ConnectorRequest request; - public AbstractRequestInvocation(T target, ConnectorRequest request, List interceptorChain) { + protected AbstractRequestInvocation(T target, ConnectorRequest request, List interceptorChain) { this.target = target; this.request = request; this.interceptorChain = interceptorChain; @@ -57,7 +57,7 @@ public ConnectorRequest getRequest() { public Object proceed() throws Exception { currentIndex++; - if(interceptorChain.size() > currentIndex) { + if (interceptorChain.size() > currentIndex) { return interceptorChain.get(currentIndex).handleInvocation(this); } else { diff --git a/connect/core/src/main/java/org/camunda/connect/impl/ConnectLogger.java b/connect/core/src/main/java/org/camunda/connect/impl/ConnectLogger.java index de6cf0be427..c9ee49976b3 100644 --- a/connect/core/src/main/java/org/camunda/connect/impl/ConnectLogger.java +++ b/connect/core/src/main/java/org/camunda/connect/impl/ConnectLogger.java @@ -22,6 +22,6 @@ public abstract class ConnectLogger extends BaseLogger { public static final String PROJECT_CODE = "CNCT"; - public static ConnectCoreLogger CORE_LOGGER = createLogger(ConnectCoreLogger.class, PROJECT_CODE, "org.camunda.bpm.connect", "01"); + public static final ConnectCoreLogger CORE_LOGGER = createLogger(ConnectCoreLogger.class, PROJECT_CODE, "org.camunda.bpm.connect", "01"); } diff --git a/connect/core/src/main/java/org/camunda/connect/impl/DebugRequestInterceptor.java b/connect/core/src/main/java/org/camunda/connect/impl/DebugRequestInterceptor.java index 3a536611058..bf753853c6c 100644 --- a/connect/core/src/main/java/org/camunda/connect/impl/DebugRequestInterceptor.java +++ b/connect/core/src/main/java/org/camunda/connect/impl/DebugRequestInterceptor.java @@ -17,8 +17,8 @@ package org.camunda.connect.impl; import org.camunda.connect.spi.ConnectorInvocation; -import org.camunda.connect.spi.ConnectorRequestInterceptor; import org.camunda.connect.spi.ConnectorRequest; +import org.camunda.connect.spi.ConnectorRequestInterceptor; /** *

@@ -60,8 +60,7 @@ public Object handleInvocation(ConnectorInvocation invocation) throws Exception target = invocation.getTarget(); if (proceed) { return invocation.proceed(); - } - else { + } else { return response; } } diff --git a/connect/core/src/main/java/org/camunda/connect/spi/CloseableConnectorResponse.java b/connect/core/src/main/java/org/camunda/connect/spi/CloseableConnectorResponse.java index 35131b9a252..6fbe5fca344 100644 --- a/connect/core/src/main/java/org/camunda/connect/spi/CloseableConnectorResponse.java +++ b/connect/core/src/main/java/org/camunda/connect/spi/CloseableConnectorResponse.java @@ -27,6 +27,6 @@ */ public interface CloseableConnectorResponse extends ConnectorResponse { - public void close(); + void close(); } diff --git a/connect/core/src/main/java/org/camunda/connect/spi/Connector.java b/connect/core/src/main/java/org/camunda/connect/spi/Connector.java index e46ea9ca07a..c4680f8a41a 100644 --- a/connect/core/src/main/java/org/camunda/connect/spi/Connector.java +++ b/connect/core/src/main/java/org/camunda/connect/spi/Connector.java @@ -87,4 +87,5 @@ public interface Connector> { * @return the result. */ ConnectorResponse execute(Q request); + } diff --git a/connect/core/src/main/java/org/camunda/connect/spi/ConnectorInvocation.java b/connect/core/src/main/java/org/camunda/connect/spi/ConnectorInvocation.java index 84492f537e2..e2931c970b3 100644 --- a/connect/core/src/main/java/org/camunda/connect/spi/ConnectorInvocation.java +++ b/connect/core/src/main/java/org/camunda/connect/spi/ConnectorInvocation.java @@ -30,7 +30,7 @@ public interface ConnectorInvocation { * The underlying raw request. * @return the raw request as executed by the connector */ - public Object getTarget(); + Object getTarget(); /** *

The connector request as created through the API. Accessing the request from an @@ -42,7 +42,7 @@ public interface ConnectorInvocation { * * @return the connector request */ - public ConnectorRequest getRequest(); + ConnectorRequest getRequest(); /** * Makes the request proceed through the interceptor chain. @@ -52,6 +52,6 @@ public interface ConnectorInvocation { * @return the result of the invocation. * @throws Exception */ - public Object proceed() throws Exception; + Object proceed() throws Exception; } diff --git a/connect/core/src/test/java/org/camunda/connect/spi/ConnectorsTest.java b/connect/core/src/test/java/org/camunda/connect/spi/ConnectorsTest.java index 6853218191d..7f07be31f7d 100644 --- a/connect/core/src/test/java/org/camunda/connect/spi/ConnectorsTest.java +++ b/connect/core/src/test/java/org/camunda/connect/spi/ConnectorsTest.java @@ -18,8 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.util.Set; - import org.camunda.connect.Connectors; import org.camunda.connect.dummy.DummyConnector; import org.junit.Test; diff --git a/connect/http-client/pom.xml b/connect/http-client/pom.xml index bff69c40e3f..27c49a6b45a 100644 --- a/connect/http-client/pom.xml +++ b/connect/http-client/pom.xml @@ -19,15 +19,8 @@ - org.apache.httpcomponents - httpclient - - - - commons-codec - commons-codec + org.apache.httpcomponents.client5 + httpclient5 diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpConnector.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpConnector.java index 54ef03c1084..a2598c48788 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpConnector.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpConnector.java @@ -21,6 +21,6 @@ public interface HttpConnector extends Connector { - static final String ID = Connectors.HTTP_CONNECTOR_ID; + String ID = Connectors.HTTP_CONNECTOR_ID; } diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpResponse.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpResponse.java index d4772364912..8b9f5a1c319 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpResponse.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/HttpResponse.java @@ -22,9 +22,9 @@ public interface HttpResponse extends CloseableConnectorResponse { - static final String PARAM_NAME_STATUS_CODE = "statusCode"; - static final String PARAM_NAME_RESPONSE = "response"; - static final String PARAM_NAME_RESPONSE_HEADERS = "headers"; + String PARAM_NAME_STATUS_CODE = "statusCode"; + String PARAM_NAME_RESPONSE = "response"; + String PARAM_NAME_RESPONSE_HEADERS = "headers"; /** * @return the HTTP status code of the response diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpConnector.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpConnector.java index 7b1f7ae276c..5a8f299415b 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpConnector.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpConnector.java @@ -18,24 +18,26 @@ import java.io.ByteArrayInputStream; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Map; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.config.RequestConfig.Builder; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpOptions; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.client.methods.HttpTrace; -import org.apache.http.entity.InputStreamEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; +import org.apache.hc.client5.http.classic.methods.HttpDelete; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpHead; +import org.apache.hc.client5.http.classic.methods.HttpOptions; +import org.apache.hc.client5.http.classic.methods.HttpPatch; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.classic.methods.HttpPut; +import org.apache.hc.client5.http.classic.methods.HttpTrace; +import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.config.RequestConfig.Builder; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.InputStreamEntity; +import org.apache.hc.core5.http.message.BasicClassicHttpRequest; import org.camunda.connect.httpclient.HttpBaseRequest; import org.camunda.connect.httpclient.HttpResponse; import org.camunda.connect.httpclient.impl.util.ParseUtil; @@ -43,15 +45,15 @@ public abstract class AbstractHttpConnector, R extends HttpResponse> extends AbstractConnector { - protected static HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; + protected static final HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; protected CloseableHttpClient httpClient; protected final Charset charset; - public AbstractHttpConnector(String connectorId) { + protected AbstractHttpConnector(String connectorId) { super(connectorId); httpClient = createClient(); - charset = Charset.forName("utf-8"); + charset = StandardCharsets.UTF_8; } protected CloseableHttpClient createClient() { @@ -68,30 +70,26 @@ public void setHttpClient(CloseableHttpClient httpClient) { @Override public R execute(Q request) { - HttpRequestBase httpRequest = createHttpRequest(request); + BasicClassicHttpRequest httpRequest = createHttpRequest(request); HttpRequestInvocation invocation = new HttpRequestInvocation(httpRequest, request, requestInterceptors, httpClient); try { - return createResponse((CloseableHttpResponse) invocation.proceed()); + return createResponse((ClassicHttpResponse) invocation.proceed()); } catch (Exception e) { throw LOG.unableToExecuteRequest(e); } - } - protected abstract R createResponse(CloseableHttpResponse response); - - @Override - public abstract Q createRequest(); + protected abstract R createResponse(ClassicHttpResponse response); /** - * creates a apache Http* representation of the request. + * creates a apache Http representation of the request. * * @param request the given request - * @return {@link HttpRequestBase} an apache representation of the request + * @return {@link BasicClassicHttpRequest} an apache representation of the request */ - protected T createHttpRequest(Q request) { + protected T createHttpRequest(Q request) { T httpRequest = createHttpRequestBase(request); applyConfig(httpRequest, request.getConfigOptions()); @@ -104,7 +102,7 @@ protected T createHttpRequest(Q request) { } @SuppressWarnings("unchecked") - protected T createHttpRequestBase(Q request) { + protected T createHttpRequestBase(Q request) { String url = request.getUrl(); if (url != null && !url.trim().isEmpty()) { String method = request.getMethod(); @@ -127,13 +125,12 @@ protected T createHttpRequestBase(Q request) { } else { throw LOG.unknownHttpMethod(method); } - } - else { + } else { throw LOG.requestUrlRequired(); } } - protected void applyHeaders(T httpRequest, Map headers) { + protected void applyHeaders(T httpRequest, Map headers) { if (headers != null) { for (Map.Entry entry : headers.entrySet()) { httpRequest.setHeader(entry.getKey(), entry.getValue()); @@ -142,31 +139,32 @@ protected void applyHeaders(T httpRequest, Map void applyPayload(T httpRequest, Q request) { + protected void applyPayload(T httpRequest, Q request) { if (httpMethodSupportsPayload(httpRequest)) { if (request.getPayload() != null) { byte[] bytes = request.getPayload().getBytes(charset); ByteArrayInputStream payload = new ByteArrayInputStream(bytes); - InputStreamEntity entity = new InputStreamEntity(payload, bytes.length); - ((HttpEntityEnclosingRequestBase) httpRequest).setEntity(entity); + InputStreamEntity entity = new InputStreamEntity(payload, bytes.length, ContentType.parse(request.getContentType())); + httpRequest.setEntity(entity); } - } - else if (request.getPayload() != null) { + } else if (request.getPayload() != null) { LOG.payloadIgnoredForHttpMethod(request.getMethod()); } } - protected boolean httpMethodSupportsPayload(T httpRequest) { - return httpRequest instanceof HttpEntityEnclosingRequestBase; + protected boolean httpMethodSupportsPayload(T httpRequest) { + return httpRequest instanceof HttpUriRequestBase; } - protected void applyConfig(T httpRequest, Map configOptions) { - Builder configBuilder = RequestConfig.custom(); - if (configOptions != null && !configOptions.isEmpty()) { - ParseUtil.parseConfigOptions(configOptions, configBuilder); + protected void applyConfig(T httpRequest, Map configOptions) { + if (httpMethodSupportsPayload(httpRequest)) { + Builder configBuilder = RequestConfig.custom(); + if (configOptions != null && !configOptions.isEmpty()) { + ParseUtil.parseConfigOptions(configOptions, configBuilder); + } + RequestConfig requestConfig = configBuilder.build(); + ((HttpUriRequestBase) httpRequest).setConfig(requestConfig); } - RequestConfig requestConfig = configBuilder.build(); - httpRequest.setConfig(requestConfig); } diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpRequest.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpRequest.java index 51db6c762cb..20c56c533dd 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpRequest.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/AbstractHttpRequest.java @@ -19,14 +19,14 @@ import java.util.HashMap; import java.util.Map; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpOptions; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpTrace; +import org.apache.hc.client5.http.classic.methods.HttpDelete; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpHead; +import org.apache.hc.client5.http.classic.methods.HttpOptions; +import org.apache.hc.client5.http.classic.methods.HttpPatch; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.classic.methods.HttpPut; +import org.apache.hc.client5.http.classic.methods.HttpTrace; import org.camunda.connect.httpclient.HttpBaseRequest; import org.camunda.connect.httpclient.HttpResponse; import org.camunda.connect.impl.AbstractConnectorRequest; @@ -34,7 +34,7 @@ public class AbstractHttpRequest, R extends HttpResponse> extends AbstractConnectorRequest { - private final HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; + private static final HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; public AbstractHttpRequest(Connector connector) { super(connector); @@ -64,12 +64,11 @@ public String getMethod() { public Q header(String field, String value) { if (field == null || field.isEmpty() || value == null || value.isEmpty()) { LOG.ignoreHeader(field, value); - } - else { + } else { Map headers = getRequestParameter(HttpBaseRequest.PARAM_NAME_REQUEST_HEADERS); if (headers == null) { - headers = new HashMap(); + headers = new HashMap<>(); setRequestParameter(HttpBaseRequest.PARAM_NAME_REQUEST_HEADERS, headers); } headers.put(field, value); @@ -82,8 +81,7 @@ public String getHeader(String field) { Map headers = getHeaders(); if (headers != null) { return headers.get(field); - } - else { + } else { return null; } } @@ -163,7 +161,7 @@ public Q configOption(String field, Object value) { Map config = getConfigOptions(); if (config == null) { - config = new HashMap(); + config = new HashMap<>(); setRequestParameter(HttpBaseRequest.PARAM_NAME_REQUEST_CONFIG, config); } config.put(field, value); diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorImpl.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorImpl.java index f5774a1988d..c02339befec 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorImpl.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorImpl.java @@ -16,7 +16,7 @@ */ package org.camunda.connect.httpclient.impl; -import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.hc.core5.http.ClassicHttpResponse; import org.camunda.connect.httpclient.HttpConnector; import org.camunda.connect.httpclient.HttpRequest; import org.camunda.connect.httpclient.HttpResponse; @@ -35,7 +35,7 @@ public HttpRequest createRequest() { return new HttpRequestImpl(this); } - protected HttpResponse createResponse(CloseableHttpResponse response) { + protected HttpResponse createResponse(ClassicHttpResponse response) { return new HttpResponseImpl(response); } diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorLogger.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorLogger.java index 8cd9a75e6d2..1ee79521652 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorLogger.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpConnectorLogger.java @@ -28,7 +28,6 @@ public void setHeader(String field, String value) { public void ignoreHeader(String field, String value) { logInfo("002", "Ignoring header with name '{}' and value '{}'", field, value); - } public void payloadIgnoredForHttpMethod(String method) { diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpLogger.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpLogger.java index e6e5ccfaefa..301452a8473 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpLogger.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpLogger.java @@ -22,5 +22,5 @@ public abstract class HttpLogger extends BaseLogger { public static final String PROJECT_CODE = "HTCL"; - public static HttpConnectorLogger HTTP_LOGGER = createLogger(HttpConnectorLogger.class, PROJECT_CODE, "org.camunda.bpm.connect.httpclient.connector", "02"); + public static final HttpConnectorLogger HTTP_LOGGER = createLogger(HttpConnectorLogger.class, PROJECT_CODE, "org.camunda.bpm.connect.httpclient.connector", "02"); } diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpRequestInvocation.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpRequestInvocation.java index dbd82938ce6..772e62d2e9e 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpRequestInvocation.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpRequestInvocation.java @@ -18,17 +18,17 @@ import java.util.List; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpRequestBase; -import org.camunda.connect.spi.ConnectorRequest; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.core5.http.message.BasicClassicHttpRequest; import org.camunda.connect.impl.AbstractRequestInvocation; +import org.camunda.connect.spi.ConnectorRequest; import org.camunda.connect.spi.ConnectorRequestInterceptor; -public class HttpRequestInvocation extends AbstractRequestInvocation { +public class HttpRequestInvocation extends AbstractRequestInvocation { protected HttpClient client; - public HttpRequestInvocation(HttpRequestBase target, ConnectorRequest request, List interceptorChain, HttpClient client) { + public HttpRequestInvocation(BasicClassicHttpRequest target, ConnectorRequest request, List interceptorChain, HttpClient client) { super(target, request, interceptorChain); this.client = client; } diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpResponseImpl.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpResponseImpl.java index cfa50aa562a..43b66e4e65f 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpResponseImpl.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/HttpResponseImpl.java @@ -21,19 +21,19 @@ import java.util.HashMap; import java.util.Map; -import org.apache.http.Header; -import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.Header; +import org.camunda.commons.utils.IoUtil; import org.camunda.connect.httpclient.HttpResponse; import org.camunda.connect.impl.AbstractCloseableConnectorResponse; -import org.camunda.commons.utils.IoUtil; public class HttpResponseImpl extends AbstractCloseableConnectorResponse implements HttpResponse { - private final HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; + private static final HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; - protected CloseableHttpResponse httpResponse; + protected ClassicHttpResponse httpResponse; - public HttpResponseImpl(CloseableHttpResponse httpResponse) { + public HttpResponseImpl(ClassicHttpResponse httpResponse) { this.httpResponse = httpResponse; } @@ -53,16 +53,13 @@ public String getHeader(String field) { Map headers = getHeaders(); if (headers != null) { return headers.get(field); - } - else { + } else { return null; } } protected void collectResponseParameters(Map responseParameters) { - if (httpResponse.getStatusLine() != null) { - responseParameters.put(PARAM_NAME_STATUS_CODE, httpResponse.getStatusLine().getStatusCode()); - } + responseParameters.put(PARAM_NAME_STATUS_CODE, httpResponse.getCode()); collectResponseHeaders(); if (httpResponse.getEntity() != null) { @@ -78,8 +75,8 @@ protected void collectResponseParameters(Map responseParameters) } protected void collectResponseHeaders() { - Map headers = new HashMap(); - for (Header header : httpResponse.getAllHeaders()) { + Map headers = new HashMap<>(); + for (Header header : httpResponse.getHeaders()) { headers.put(header.getName(), header.getValue()); } responseParameters.put(PARAM_NAME_RESPONSE_HEADERS, headers); diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/RequestConfigOption.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/RequestConfigOption.java index ab38e78532e..10c236abfb9 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/RequestConfigOption.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/RequestConfigOption.java @@ -16,12 +16,12 @@ */ package org.camunda.connect.httpclient.impl; -import java.net.InetAddress; import java.util.Collection; import java.util.function.BiConsumer; -import org.apache.http.HttpHost; -import org.apache.http.client.config.RequestConfig.Builder; +import org.apache.hc.client5.http.config.RequestConfig.Builder; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.util.Timeout; public enum RequestConfigOption { @@ -29,43 +29,37 @@ public enum RequestConfigOption { (builder, value) -> builder.setAuthenticationEnabled((boolean) value)), CIRCULAR_REDIRECTS_ALLOWED("circular-redirects-allowed", (builder, value) -> builder.setCircularRedirectsAllowed((boolean) value)), - CONNECTION_TIMEOUT("connection-timeout", - (builder, value) -> builder.setConnectTimeout((int) value)), + CONNECT_TIMEOUT("connect-timeout", + (builder, value) -> builder.setConnectTimeout((Timeout) value)), + CONNECTION_KEEP_ALIVE("connection-keep-alive", + (builder, value) -> builder.setConnectionKeepAlive((Timeout) value)), CONNECTION_REQUEST_TIMEOUT("connection-request-timeout", - (builder, value) -> builder.setConnectionRequestTimeout((int) value)), + (builder, value) -> builder.setConnectionRequestTimeout((Timeout) value)), CONTENT_COMPRESSION_ENABLED("content-compression-enabled", (builder, value) -> builder.setContentCompressionEnabled((boolean) value)), COOKIE_SPEC("cookie-spec", (builder, value) -> builder.setCookieSpec((String) value)), - DECOMPRESSION_ENABLED("decompression-enabled", - (builder, value) -> builder.setDecompressionEnabled((boolean) value)), EXPECT_CONTINUE_ENABLED("expect-continue-enabled", (builder, value) -> builder.setExpectContinueEnabled((boolean) value)), - LOCAL_ADDRESS("local-address", - (builder, value) -> builder.setLocalAddress((InetAddress) value)), + HARD_CANCELLATION_ENABLED("hard-cancellation-enabled", + (builder, value) -> builder.setHardCancellationEnabled((boolean) value)), MAX_REDIRECTS("max-redirects", (builder, value) -> builder.setMaxRedirects((int) value)), - NORMALIZE_URI("normalize-uri", - (builder, value) -> builder.setNormalizeUri((boolean) value)), PROXY("proxy", (builder, value) -> builder.setProxy((HttpHost) value)), PROXY_PREFERRED_AUTH_SCHEMES("proxy-preferred-auth-scheme", (builder, value) -> builder.setProxyPreferredAuthSchemes((Collection) value)), - REDIRECTS_ENABLED("relative-redirects-allowed", + REDIRECTS_ENABLED("redirects-enabled", (builder, value) -> builder.setRedirectsEnabled((boolean) value)), - RELATIVE_REDIRECTS_ALLOWED("relative-redirects-allowed", - (builder, value) -> builder.setRelativeRedirectsAllowed((boolean) value)), - SOCKET_TIMEOUT("socket-timeout", - (builder, value) -> builder.setSocketTimeout((int) value)), - STALE_CONNECTION_CHECK_ENABLED("stale-connection-check-enabled", - (builder, value) -> builder.setStaleConnectionCheckEnabled((boolean) value)), + RESPONSE_TIMEOUT("response-timeout", + (builder, value) -> builder.setResponseTimeout((Timeout) value)), TARGET_PREFERRED_AUTH_SCHEMES("target-preferred-auth-schemes", (builder, value) -> builder.setTargetPreferredAuthSchemes((Collection) value)); - private String name; - private BiConsumer consumer; + private final String name; + private final BiConsumer consumer; - private RequestConfigOption(String name, BiConsumer consumer) { + RequestConfigOption(String name, BiConsumer consumer) { this.name = name; this.consumer = consumer; } @@ -75,7 +69,7 @@ public String getName() { } public void apply(Builder configBuilder, Object value) { - this.consumer.accept(configBuilder, value); + consumer.accept(configBuilder, value); } } diff --git a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/util/ParseUtil.java b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/util/ParseUtil.java index 9cd0293de55..f8e00f1e3d0 100644 --- a/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/util/ParseUtil.java +++ b/connect/http-client/src/main/java/org/camunda/connect/httpclient/impl/util/ParseUtil.java @@ -18,14 +18,18 @@ import java.util.Map; -import org.apache.http.client.config.RequestConfig.Builder; -import org.camunda.connect.httpclient.impl.RequestConfigOption; -import org.camunda.connect.httpclient.impl.HttpConnectorLogger; +import org.apache.hc.client5.http.config.RequestConfig.Builder; import org.camunda.connect.httpclient.impl.HttpLogger; +import org.camunda.connect.httpclient.impl.HttpConnectorLogger; +import org.camunda.connect.httpclient.impl.RequestConfigOption; + +public final class ParseUtil { -public class ParseUtil { + private static final HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; - protected static HttpConnectorLogger LOG = HttpLogger.HTTP_LOGGER; + private ParseUtil() { + /* hidden */ + } public static void parseConfigOptions(Map configOptions, Builder configBuilder) { for (RequestConfigOption option : RequestConfigOption.values()) { diff --git a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorSystemPropertiesTest.java b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorSystemPropertiesTest.java index 6511f94fdae..1070ac772f6 100644 --- a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorSystemPropertiesTest.java +++ b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorSystemPropertiesTest.java @@ -16,21 +16,25 @@ */ package org.camunda.connect.httpclient; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; + import java.util.HashSet; import java.util.Set; -import org.apache.http.protocol.HTTP; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import org.apache.hc.core5.http.HttpHeaders; import org.camunda.connect.httpclient.impl.HttpConnectorImpl; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import static com.github.tomakehurst.wiremock.client.WireMock.*; - -import com.github.tomakehurst.wiremock.core.WireMockConfiguration; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - /** * Since Apache HTTP client makes it extremely hard to test the proper configuration * of a http client, this is more of an integration test that checks that a @@ -50,7 +54,7 @@ public class HttpConnectorSystemPropertiesTest { @Before public void setUp() { - updatedSystemProperties = new HashSet(); + updatedSystemProperties = new HashSet<>(); wireMockRule.stubFor(get(urlEqualTo("/")).willReturn(aResponse().withStatus(200))); } @@ -65,8 +69,7 @@ public void setSystemProperty(String property, String value) { if (!System.getProperties().containsKey(property)) { updatedSystemProperties.add(property); System.setProperty(property, value); - } - else { + } else { throw new RuntimeException("Cannot perform test: System property " + property + " is already set. Will not attempt to overwrite this property."); } @@ -83,7 +86,7 @@ public void shouldSetUserAgentFromSystemProperty() { customConnector.createRequest().url("http://localhost:" + PORT).get().execute(); // then - verify(getRequestedFor(urlEqualTo("/")).withHeader(HTTP.USER_AGENT, equalTo("foo"))); + verify(getRequestedFor(urlEqualTo("/")).withHeader(HttpHeaders.USER_AGENT, equalTo("foo"))); } } diff --git a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorTest.java b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorTest.java index 79040343a64..29fa0ebb311 100644 --- a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorTest.java +++ b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpConnectorTest.java @@ -21,16 +21,16 @@ import java.io.IOException; -import org.apache.http.Header; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpOptions; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.client.methods.HttpTrace; +import org.apache.hc.client5.http.classic.methods.HttpDelete; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpHead; +import org.apache.hc.client5.http.classic.methods.HttpOptions; +import org.apache.hc.client5.http.classic.methods.HttpPatch; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.classic.methods.HttpPut; +import org.apache.hc.client5.http.classic.methods.HttpTrace; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.message.BasicClassicHttpRequest; import org.camunda.commons.utils.IoUtil; import org.camunda.connect.ConnectorRequestException; import org.camunda.connect.Connectors; @@ -133,10 +133,10 @@ public void shouldCreateHttpTraceRequest() { } @Test - public void shouldSetUrlOnHttpRequest() { + public void shouldSetUrlOnHttpRequest() throws Exception { connector.createRequest().url(EXAMPLE_URL).get().execute(); HttpGet request = interceptor.getTarget(); - assertThat(request.getURI().toASCIIString()).isEqualTo(EXAMPLE_URL); + assertThat(request.getUri().toASCIIString()).isEqualTo(EXAMPLE_URL); } @Test @@ -153,7 +153,7 @@ public void shouldSetContentTypeOnHttpRequest() { public void shouldSetHeadersOnHttpRequest() { connector.createRequest().url(EXAMPLE_URL).header("foo", "bar").header("hello", "world").get().execute(); HttpGet request = interceptor.getTarget(); - Header[] headers = request.getAllHeaders(); + Header[] headers = request.getHeaders(); assertThat(headers).hasSize(2); } @@ -174,12 +174,12 @@ public void shouldSetContentLength() { assertThat(contentLength).isEqualTo(EXAMPLE_PAYLOAD.length()); } - protected void verifyHttpRequest(Class requestClass) { + protected void verifyHttpRequest(Class requestClass) { Object target = interceptor.getTarget(); assertThat(target).isInstanceOf(requestClass); HttpRequest request = interceptor.getRequest(); - HttpRequestBase requestBase = (HttpRequestBase) target; + BasicClassicHttpRequest requestBase = (BasicClassicHttpRequest) target; assertThat(requestBase.getMethod()).isEqualTo(request.getMethod()); } diff --git a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestConfigTest.java b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestConfigTest.java index bff7e068e39..5503ce07b58 100644 --- a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestConfigTest.java +++ b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestConfigTest.java @@ -16,48 +16,40 @@ */ package org.camunda.connect.httpclient; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static org.assertj.core.api.Assertions.assertThat; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.AUTHENTICATION_ENABLED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.CIRCULAR_REDIRECTS_ALLOWED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.CONNECTION_REQUEST_TIMEOUT; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.CONNECTION_TIMEOUT; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.CONTENT_COMPRESSION_ENABLED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.COOKIE_SPEC; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.DECOMPRESSION_ENABLED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.EXPECT_CONTINUE_ENABLED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.LOCAL_ADDRESS; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.MAX_REDIRECTS; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.NORMALIZE_URI; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.PROXY; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.PROXY_PREFERRED_AUTH_SCHEMES; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.REDIRECTS_ENABLED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.RELATIVE_REDIRECTS_ALLOWED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.SOCKET_TIMEOUT; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.STALE_CONNECTION_CHECK_ENABLED; -import static org.camunda.connect.httpclient.impl.RequestConfigOption.TARGET_PREFERRED_AUTH_SCHEMES; - -import java.net.InetAddress; -import java.net.UnknownHostException; +import static org.junit.Assert.fail; + +import java.net.SocketTimeoutException; import java.util.ArrayList; import java.util.Map; -import org.apache.http.HttpHost; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.config.RequestConfig.Builder; -import org.apache.http.conn.ConnectTimeoutException; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.util.Timeout; import org.camunda.connect.ConnectorRequestException; import org.camunda.connect.httpclient.impl.HttpConnectorImpl; +import org.camunda.connect.httpclient.impl.RequestConfigOption; import org.camunda.connect.httpclient.impl.util.ParseUtil; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.mockito.internal.util.reflection.Whitebox; public class HttpRequestConfigTest { public static final String EXAMPLE_URL = "http://camunda.org/example"; - public static final String EXAMPLE_CONTENT_TYPE = "application/json"; - public static final String EXAMPLE_PAYLOAD = "camunda"; + + public static final int PORT = 51234; + + @Rule + public WireMockRule wireMockRule = new WireMockRule( + WireMockConfiguration.wireMockConfig().port(PORT)); protected HttpConnector connector; @@ -70,10 +62,10 @@ public void createConnector() { public void shouldParseAuthenticationEnabled() { // given HttpRequest request = connector.createRequest() - .configOption(AUTHENTICATION_ENABLED.getName(), false); + .configOption(RequestConfigOption.AUTHENTICATION_ENABLED.getName(), false); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when @@ -87,10 +79,10 @@ public void shouldParseAuthenticationEnabled() { public void shouldParseCircularRedirectsAllowed() { // given HttpRequest request = connector.createRequest() - .configOption(CIRCULAR_REDIRECTS_ALLOWED.getName(), true); + .configOption(RequestConfigOption.CIRCULAR_REDIRECTS_ALLOWED.getName(), true); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when @@ -101,47 +93,47 @@ public void shouldParseCircularRedirectsAllowed() { } @Test - public void shouldParseConnectionTimeout() { + public void shouldParseConnectTimeout() { // given HttpRequest request = connector.createRequest() - .configOption(CONNECTION_TIMEOUT.getName(), -2); + .configOption(RequestConfigOption.CONNECT_TIMEOUT.getName(), Timeout.ofSeconds(10)); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.getConnectTimeout()).isEqualTo(-2); + assertThat(config.getConnectTimeout()).isEqualTo(Timeout.ofSeconds(10)); } @Test public void shouldParseConnectionRequestTimeout() { // given HttpRequest request = connector.createRequest() - .configOption(CONNECTION_REQUEST_TIMEOUT.getName(), -2); + .configOption(RequestConfigOption.CONNECTION_REQUEST_TIMEOUT.getName(), Timeout.ofSeconds(10)); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.getConnectionRequestTimeout()).isEqualTo(-2); + assertThat(config.getConnectionRequestTimeout()).isEqualTo(Timeout.ofSeconds(10)); } @Test public void shouldParseContentCompressionEnabled() { // given HttpRequest request = connector.createRequest() - .configOption(CONTENT_COMPRESSION_ENABLED.getName(), false); + .configOption(RequestConfigOption.CONTENT_COMPRESSION_ENABLED.getName(), false); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when @@ -155,10 +147,10 @@ public void shouldParseContentCompressionEnabled() { public void shouldParseCookieSpec() { // given HttpRequest request = connector.createRequest() - .configOption(COOKIE_SPEC.getName(), "test"); + .configOption(RequestConfigOption.COOKIE_SPEC.getName(), "test"); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when @@ -168,66 +160,14 @@ public void shouldParseCookieSpec() { assertThat(config.getCookieSpec()).isEqualTo("test"); } - @Test - public void shouldParseDecompressionEnabled() { - // given - HttpRequest request = connector.createRequest() - .configOption(DECOMPRESSION_ENABLED.getName(), false); - Map configOptions = request.getConfigOptions(); - - Builder configBuilder = RequestConfig.custom(); - ParseUtil.parseConfigOptions(configOptions, configBuilder); - - // when - RequestConfig config = configBuilder.build(); - - // then - assertThat(config.isDecompressionEnabled()).isFalse(); - } - - @Test - public void shouldParseExpectContinueEnabled() { - // given - HttpRequest request = connector.createRequest() - .configOption(EXPECT_CONTINUE_ENABLED.getName(), true); - Map configOptions = request.getConfigOptions(); - - Builder configBuilder = RequestConfig.custom(); - ParseUtil.parseConfigOptions(configOptions, configBuilder); - - // when - RequestConfig config = configBuilder.build(); - - // then - assertThat(config.isExpectContinueEnabled()).isTrue(); - } - - @Test - public void shouldParseLocalAddress() throws UnknownHostException { - // given - InetAddress testAddress = InetAddress.getByName("127.0.0.1"); - HttpRequest request = connector.createRequest() - .configOption(LOCAL_ADDRESS.getName(), testAddress); - Map configOptions = request.getConfigOptions(); - - Builder configBuilder = RequestConfig.custom(); - ParseUtil.parseConfigOptions(configOptions, configBuilder); - - // when - RequestConfig config = configBuilder.build(); - - // then - assertThat(config.getLocalAddress()).isEqualTo(testAddress); - } - @Test public void shouldParseMaxRedirects() { // given HttpRequest request = connector.createRequest() - .configOption(MAX_REDIRECTS.getName(), -2); + .configOption(RequestConfigOption.MAX_REDIRECTS.getName(), -2); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when @@ -238,145 +178,142 @@ public void shouldParseMaxRedirects() { } @Test - public void shouldParseNormalizeUri() { + public void shouldParseProxy() { // given + HttpHost testHost = new HttpHost("test"); HttpRequest request = connector.createRequest() - .configOption(NORMALIZE_URI.getName(), false); + .configOption(RequestConfigOption.PROXY.getName(), testHost); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.isNormalizeUri()).isFalse(); + assertThat(config.getProxy()).isEqualTo(testHost); } @Test - public void shouldParseProxy() { + public void shouldParseProxyPreferredAuthSchemes() { // given - HttpHost testHost = new HttpHost("test"); + ArrayList testArray = new ArrayList<>(); HttpRequest request = connector.createRequest() - .configOption(PROXY.getName(), testHost); + .configOption(RequestConfigOption.PROXY_PREFERRED_AUTH_SCHEMES.getName(), testArray); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.getProxy()).isEqualTo(testHost); + assertThat(config.getProxyPreferredAuthSchemes()).isEqualTo(testArray); } @Test - public void shouldParseProxyPreferredAuthSchemes() { + public void shouldParseRedirectsEnabled() { // given - ArrayList testArray = new ArrayList(); HttpRequest request = connector.createRequest() - .configOption(PROXY_PREFERRED_AUTH_SCHEMES.getName(), testArray); + .configOption(RequestConfigOption.REDIRECTS_ENABLED.getName(), false); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.getProxyPreferredAuthSchemes()).isEqualTo(testArray); + assertThat(config.isRedirectsEnabled()).isFalse(); } @Test - public void shouldParseRedirectsEnabled() { + public void shouldParseTargetPreferredAuthSchemes() { // given + ArrayList testArray = new ArrayList<>(); HttpRequest request = connector.createRequest() - .configOption(REDIRECTS_ENABLED.getName(), false); + .configOption(RequestConfigOption.TARGET_PREFERRED_AUTH_SCHEMES.getName(), testArray); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.isRedirectsEnabled()).isFalse(); + assertThat(config.getTargetPreferredAuthSchemes()).isEqualTo(testArray); } @Test - public void shouldParseRelativeRedirectsAllowed() { + public void shouldParseConnectionKeepAlive() { // given HttpRequest request = connector.createRequest() - .configOption(RELATIVE_REDIRECTS_ALLOWED.getName(), false); + .configOption(RequestConfigOption.CONNECTION_KEEP_ALIVE.getName(), Timeout.ofSeconds(10)); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.isRelativeRedirectsAllowed()).isFalse(); + assertThat(config.getConnectionKeepAlive()).isEqualTo(Timeout.ofSeconds(10)); } - @Test - public void shouldParseSocketTimeout() { + public void shouldParseExpectContinueEnabled() { // given HttpRequest request = connector.createRequest() - .configOption(SOCKET_TIMEOUT.getName(), -2); + .configOption(RequestConfigOption.EXPECT_CONTINUE_ENABLED.getName(), true); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.getSocketTimeout()).isEqualTo(-2); + assertThat(config.isExpectContinueEnabled()).isTrue(); } - @Test - public void shouldParseStaleConnectionCheckEnabled() { + public void shouldParseHardCancellationEnabled() { // given HttpRequest request = connector.createRequest() - .configOption(STALE_CONNECTION_CHECK_ENABLED.getName(), true); + .configOption(RequestConfigOption.HARD_CANCELLATION_ENABLED.getName(), true); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.isStaleConnectionCheckEnabled()).isTrue(); + assertThat(config.isHardCancellationEnabled()).isTrue(); } - @Test - public void shouldParseTargetPreferredAuthSchemes() { + public void shouldParseResponseTimeout() { // given - ArrayList testArray = new ArrayList(); HttpRequest request = connector.createRequest() - .configOption(TARGET_PREFERRED_AUTH_SCHEMES.getName(), testArray); + .configOption(RequestConfigOption.RESPONSE_TIMEOUT.getName(), Timeout.ofSeconds(10)); Map configOptions = request.getConfigOptions(); - Builder configBuilder = RequestConfig.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); ParseUtil.parseConfigOptions(configOptions, configBuilder); // when RequestConfig config = configBuilder.build(); // then - assertThat(config.getTargetPreferredAuthSchemes()).isEqualTo(testArray); + assertThat(config.getResponseTimeout()).isEqualTo(Timeout.ofSeconds(10)); } @Test @@ -384,10 +321,10 @@ public void shouldNotChangeDefaultConfig() { // given HttpClient client = (HttpClient) Whitebox.getInternalState(connector, "httpClient"); connector.createRequest().url(EXAMPLE_URL).get() - .configOption(CONNECTION_TIMEOUT.getName(), -2) - .configOption(SOCKET_TIMEOUT.getName(), -2) - .configOption(CONNECTION_REQUEST_TIMEOUT.getName(), -2) - .configOption(MAX_REDIRECTS.getName(), 0) + .configOption(RequestConfigOption.CONNECT_TIMEOUT.getName(), Timeout.ofSeconds(10)) + .configOption(RequestConfigOption.CONNECTION_REQUEST_TIMEOUT.getName(), Timeout.ofSeconds(10)) + .configOption(RequestConfigOption.CONNECTION_KEEP_ALIVE.getName(), Timeout.ofSeconds(10)) + .configOption(RequestConfigOption.MAX_REDIRECTS.getName(), 0) .execute(); // when @@ -395,37 +332,42 @@ public void shouldNotChangeDefaultConfig() { // then assertThat(config.getMaxRedirects()).isEqualTo(50); - assertThat(config.getConnectTimeout()).isEqualTo(-1); - assertThat(config.getConnectionRequestTimeout()).isEqualTo(-1); - assertThat(config.getSocketTimeout()).isEqualTo(-1); + assertThat(config.getConnectTimeout()).isNull(); + assertThat(config.getConnectionRequestTimeout()).isEqualTo(Timeout.ofMinutes(3)); + assertThat(config.getConnectionKeepAlive()).isEqualTo(Timeout.ofMinutes(3)); } @Test public void shouldThrowTimeoutException() { try { + // given + wireMockRule.stubFor(get(urlEqualTo("/")).willReturn(aResponse().withFixedDelay(1000).withStatus(200))); + // when - connector.createRequest().url(EXAMPLE_URL).get() - .configOption(CONNECTION_TIMEOUT.getName(), 1) + connector.createRequest().url("http://localhost:" + PORT).get() + .configOption(RequestConfigOption.RESPONSE_TIMEOUT.getName(), Timeout.ofMilliseconds(100)) .execute(); + fail("No exception thrown"); } catch (ConnectorRequestException e) { // then assertThat(e).hasMessageContaining("Unable to execute HTTP request"); - assertThat(e).hasCauseExactlyInstanceOf(ConnectTimeoutException.class); + assertThat(e).hasCauseExactlyInstanceOf(SocketTimeoutException.class); } } @Test - public void shouldThrowClassCastExceptionStringToInt() { + public void shouldThrowClassCastExceptionStringToTimeout() { try { // when connector.createRequest().url(EXAMPLE_URL).get() - .configOption(CONNECTION_TIMEOUT.getName(), "-1") + .configOption(RequestConfigOption.CONNECT_TIMEOUT.getName(), "0") .execute(); + fail("No exception thrown"); } catch (ConnectorRequestException e) { // then - assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + CONNECTION_TIMEOUT.getName()); + assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + RequestConfigOption.CONNECT_TIMEOUT.getName()); assertThat(e).hasCauseInstanceOf(ClassCastException.class); - assertThat(e.getCause()).hasMessageContaining("java.lang.String cannot be cast to class java.lang.Integer"); + assertThat(e.getCause()).hasMessageContaining("java.lang.String cannot be cast to class org.apache.hc.core5.util.Timeout"); } } @@ -434,11 +376,12 @@ public void shouldThrowClassCastExceptionStringToBoolean() { try { // when connector.createRequest().url(EXAMPLE_URL).get() - .configOption(AUTHENTICATION_ENABLED.getName(), "true") + .configOption(RequestConfigOption.AUTHENTICATION_ENABLED.getName(), "true") .execute(); + fail("No exception thrown"); } catch (ConnectorRequestException e) { // then - assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + AUTHENTICATION_ENABLED.getName()); + assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + RequestConfigOption.AUTHENTICATION_ENABLED.getName()); assertThat(e).hasCauseInstanceOf(ClassCastException.class); assertThat(e.getCause()).hasMessageContaining("java.lang.String cannot be cast to class java.lang.Boolean"); } @@ -449,13 +392,14 @@ public void shouldThrowClassCastExceptionStringToHttpHost() { try { // when connector.createRequest().url(EXAMPLE_URL).get() - .configOption(PROXY.getName(), "proxy") - .execute(); + .configOption(RequestConfigOption.PROXY.getName(), "proxy") + .execute(); + fail("No exception thrown"); } catch (ConnectorRequestException e) { // then - assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + PROXY.getName()); + assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + RequestConfigOption.PROXY.getName()); assertThat(e).hasCauseInstanceOf(ClassCastException.class); - assertThat(e.getCause()).hasMessageContaining("java.lang.String cannot be cast to class org.apache.http.HttpHost"); + assertThat(e.getCause()).hasMessageContaining("java.lang.String cannot be cast to class org.apache.hc.core5.http.HttpHost"); } } @@ -464,11 +408,12 @@ public void shouldThrowClassCastExceptionIntToHttpHost() { try { // when connector.createRequest().url(EXAMPLE_URL).get() - .configOption(PROXY_PREFERRED_AUTH_SCHEMES.getName(), 0) - .execute(); + .configOption(RequestConfigOption.PROXY_PREFERRED_AUTH_SCHEMES.getName(), 0) + .execute(); + fail("No exception thrown"); } catch (ConnectorRequestException e) { // then - assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + PROXY_PREFERRED_AUTH_SCHEMES.getName()); + assertThat(e).hasMessageContaining("Invalid value for request configuration option: " + RequestConfigOption.PROXY_PREFERRED_AUTH_SCHEMES.getName()); assertThat(e).hasCauseInstanceOf(ClassCastException.class); assertThat(e.getCause()).hasMessageContaining("java.lang.Integer cannot be cast to class java.util.Collection"); } diff --git a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestTest.java b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestTest.java index 08cc564f320..1a22b17eb85 100644 --- a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestTest.java +++ b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpRequestTest.java @@ -21,14 +21,14 @@ import java.util.HashMap; import java.util.Map; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpOptions; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpTrace; +import org.apache.hc.client5.http.classic.methods.HttpDelete; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpHead; +import org.apache.hc.client5.http.classic.methods.HttpOptions; +import org.apache.hc.client5.http.classic.methods.HttpPatch; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.classic.methods.HttpPut; +import org.apache.hc.client5.http.classic.methods.HttpTrace; import org.camunda.connect.Connectors; import org.junit.Before; import org.junit.Test; @@ -148,7 +148,7 @@ public void setRequestParameters() { request.setRequestParameter("hello", "world"); - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("foo", "bar"); params.put("number", 42); request.setRequestParameters(params); @@ -166,13 +166,13 @@ public void setConfigOption() { HttpRequest request = connector.createRequest() .configOption("object-field", value) .configOption("int-field", 15) - .configOption("long-field", 15l) + .configOption("long-field", 15L) .configOption("boolean-field", true) .configOption("string-field", "string-value"); assertThat(request.getConfigOption("object-field")).isEqualTo(value); assertThat(request.getConfigOption("int-field")).isEqualTo(15); - assertThat(request.getConfigOption("long-field")).isEqualTo(15l); + assertThat(request.getConfigOption("long-field")).isEqualTo(15L); assertThat(request.getConfigOption("boolean-field")).isEqualTo(true); assertThat(request.getConfigOption("string-field")).isEqualTo("string-value"); } diff --git a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpResponseTest.java b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpResponseTest.java index a9664e62066..cf7db435dd3 100644 --- a/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpResponseTest.java +++ b/connect/http-client/src/test/java/org/camunda/connect/httpclient/HttpResponseTest.java @@ -37,7 +37,7 @@ public void getConnector() { @Test public void testResponseCode() { - testResponse.statusCode(123); + testResponse.code(123); HttpResponse response = getResponse(); assertThat(response.getStatusCode()).isEqualTo(123); } diff --git a/connect/http-client/src/test/java/org/camunda/connect/httpclient/TestResponse.java b/connect/http-client/src/test/java/org/camunda/connect/httpclient/TestResponse.java index 07641d0cec0..d1466a0af11 100644 --- a/connect/http-client/src/test/java/org/camunda/connect/httpclient/TestResponse.java +++ b/connect/http-client/src/test/java/org/camunda/connect/httpclient/TestResponse.java @@ -16,27 +16,28 @@ */ package org.camunda.connect.httpclient; -import java.io.IOException; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.message.BasicHttpResponse; -import org.apache.http.HttpVersion; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; -public class TestResponse extends BasicHttpResponse implements CloseableHttpResponse { + +public class TestResponse extends BasicHttpResponse implements ClassicHttpResponse { + + private HttpEntity entity; public TestResponse() { - this(HttpVersion.HTTP_1_1, 200, "OK"); + this(200, "OK"); } - public TestResponse(ProtocolVersion ver, int code, String reason) { - super(ver, code, reason); + public TestResponse(int code, String reason) { + super(code, reason); } - public TestResponse statusCode(int statusCode) { - setStatusCode(statusCode); + public TestResponse code(int code) { + setCode(code); return this; } @@ -52,15 +53,24 @@ public TestResponse payload(String payload) { public TestResponse payload(String payload, ContentType contentType) { if (payload != null) { setEntity(new StringEntity(payload, contentType)); - } - else { + } else { setEntity(null); } return this; } - public void close() throws IOException { + @Override + public HttpEntity getEntity() { + return entity; + } + @Override + public void setEntity(HttpEntity entity) { + this.entity = entity; } + @Override + public void close() { + /* NOP */ + } } diff --git a/connect/pom.xml b/connect/pom.xml index 170267a4d3d..6e2946dee7a 100644 --- a/connect/pom.xml +++ b/connect/pom.xml @@ -14,7 +14,6 @@ pom - 1.15 1.6.0 1.9.5 1.58 @@ -44,17 +43,11 @@ - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 ${version.httpclient} - - commons-codec - commons-codec - ${commons-codec.version} - - junit junit diff --git a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/SoapHttpConnector.java b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/SoapHttpConnector.java index 8394f90e2d3..3a4cd08fd28 100644 --- a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/SoapHttpConnector.java +++ b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/SoapHttpConnector.java @@ -21,6 +21,6 @@ public interface SoapHttpConnector extends Connector { - static final String ID = Connectors.SOAP_HTTP_CONNECTOR_ID; + String ID = Connectors.SOAP_HTTP_CONNECTOR_ID; } diff --git a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorImpl.java b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorImpl.java index 446dfaea1aa..ea73d2ca967 100644 --- a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorImpl.java +++ b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorImpl.java @@ -16,8 +16,8 @@ */ package org.camunda.connect.httpclient.soap.impl; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpRequestBase; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.message.BasicClassicHttpRequest; import org.camunda.connect.httpclient.impl.AbstractHttpConnector; import org.camunda.connect.httpclient.impl.AbstractHttpRequest; import org.camunda.connect.httpclient.soap.SoapHttpConnector; @@ -26,7 +26,7 @@ public class SoapHttpConnectorImpl extends AbstractHttpConnector implements SoapHttpConnector { - protected static final SoapHttpConnectorLogger LOG = SoapHttpLogger.SOAP_CONNECTOR_LOGGER; + protected static final SoapHttpConnectorLogger LOG = SoapHttpLogger.SOAP_HTTP_CONNECTOR_LOGGER; public SoapHttpConnectorImpl() { super(SoapHttpConnector.ID); @@ -40,20 +40,20 @@ public SoapHttpRequest createRequest() { return new SoapHttpRequestImpl(this); } - protected SoapHttpResponse createResponse(CloseableHttpResponse response) { + protected SoapHttpResponse createResponse(ClassicHttpResponse response) { return new SoapHttpResponseImpl(response); } @Override public SoapHttpResponse execute(SoapHttpRequest request) { // always use the POST method - ((AbstractHttpRequest) request).post(); + ((AbstractHttpRequest) request).post(); return super.execute(request); } @Override - protected void applyPayload(T httpRequest, SoapHttpRequest request) { + protected void applyPayload(T httpRequest, SoapHttpRequest request) { // SOAP requires soap envelop body if (request.getPayload() == null || request.getPayload().trim().isEmpty()) { throw LOG.noPayloadSet(); diff --git a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorProviderImpl.java b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorProviderImpl.java index 9d44c583c9c..eae6df9c752 100644 --- a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorProviderImpl.java +++ b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpConnectorProviderImpl.java @@ -17,9 +17,9 @@ package org.camunda.connect.httpclient.soap.impl; import org.camunda.connect.httpclient.soap.SoapHttpConnector; -import org.camunda.connect.spi.ConnectorProvider; +import org.camunda.connect.httpclient.soap.SoapHttpConnectorProvider; -public class SoapHttpConnectorProviderImpl implements ConnectorProvider { +public class SoapHttpConnectorProviderImpl implements SoapHttpConnectorProvider { public String getConnectorId() { return SoapHttpConnector.ID; diff --git a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpLogger.java b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpLogger.java index d28018b56d4..547a377d65a 100644 --- a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpLogger.java +++ b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpLogger.java @@ -22,6 +22,6 @@ public abstract class SoapHttpLogger extends BaseLogger { public static final String PROJECT_CODE = "SOAPC"; - public static SoapHttpConnectorLogger SOAP_CONNECTOR_LOGGER = createLogger(SoapHttpConnectorLogger.class, PROJECT_CODE, "org.camunda.bpm.connect.soap.httpclient.connector", "01"); + public static final SoapHttpConnectorLogger SOAP_HTTP_CONNECTOR_LOGGER = createLogger(SoapHttpConnectorLogger.class, PROJECT_CODE, "org.camunda.bpm.connect.soap.httpclient.connector", "01"); } diff --git a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpRequestImpl.java b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpRequestImpl.java index 9ccf32e1a32..db80f65502e 100644 --- a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpRequestImpl.java +++ b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpRequestImpl.java @@ -16,7 +16,8 @@ */ package org.camunda.connect.httpclient.soap.impl; -import org.apache.http.client.methods.HttpPost; + +import org.apache.hc.client5.http.classic.methods.HttpPost; import org.camunda.connect.httpclient.impl.AbstractHttpRequest; import org.camunda.connect.httpclient.soap.SoapHttpConnector; import org.camunda.connect.httpclient.soap.SoapHttpRequest; @@ -24,7 +25,7 @@ public class SoapHttpRequestImpl extends AbstractHttpRequest implements SoapHttpRequest { - protected static final SoapHttpConnectorLogger LOG = SoapHttpLogger.SOAP_CONNECTOR_LOGGER; + protected static final SoapHttpConnectorLogger LOG = SoapHttpLogger.SOAP_HTTP_CONNECTOR_LOGGER; public SoapHttpRequestImpl(SoapHttpConnector connector) { super(connector); diff --git a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpResponseImpl.java b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpResponseImpl.java index 8067f000f95..a93e330bf85 100644 --- a/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpResponseImpl.java +++ b/connect/soap-http-client/src/main/java/org/camunda/connect/httpclient/soap/impl/SoapHttpResponseImpl.java @@ -16,13 +16,13 @@ */ package org.camunda.connect.httpclient.soap.impl; -import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.hc.core5.http.ClassicHttpResponse; import org.camunda.connect.httpclient.impl.HttpResponseImpl; import org.camunda.connect.httpclient.soap.SoapHttpResponse; public class SoapHttpResponseImpl extends HttpResponseImpl implements SoapHttpResponse { - public SoapHttpResponseImpl(CloseableHttpResponse httpResponse) { + public SoapHttpResponseImpl(ClassicHttpResponse httpResponse) { super(httpResponse); } diff --git a/connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpConnectorSystemPropertiesTest.java b/connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpConnectorSystemPropertiesTest.java similarity index 84% rename from connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpConnectorSystemPropertiesTest.java rename to connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpConnectorSystemPropertiesTest.java index 4981b09fcbb..ee409b16845 100644 --- a/connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpConnectorSystemPropertiesTest.java +++ b/connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpConnectorSystemPropertiesTest.java @@ -14,32 +14,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.camunda.connect.soap.httpclient; +package org.camunda.connect.httpclient.soap; -import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.verify; import java.util.HashSet; import java.util.Set; -import org.apache.http.protocol.HTTP; -import org.camunda.connect.httpclient.HttpConnector; -import org.camunda.connect.httpclient.impl.HttpConnectorImpl; -import org.camunda.connect.httpclient.soap.SoapHttpConnector; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import org.apache.hc.core5.http.HttpHeaders; import org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorImpl; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import com.github.tomakehurst.wiremock.core.WireMockConfiguration; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - /** * Since Apache HTTP client makes it extremely hard to test the proper configuration * of a http client, this is more of an integration test that checks that a @@ -59,7 +54,7 @@ public class SoapHttpConnectorSystemPropertiesTest { @Before public void setUp() { - updatedSystemProperties = new HashSet(); + updatedSystemProperties = new HashSet<>(); wireMockRule.stubFor(get(urlEqualTo("/")).willReturn(aResponse().withStatus(200))); } @@ -74,8 +69,7 @@ public void setSystemProperty(String property, String value) { if (!System.getProperties().containsKey(property)) { updatedSystemProperties.add(property); System.setProperty(property, value); - } - else { + } else { throw new RuntimeException("Cannot perform test: System property " + property + " is already set. Will not attempt to overwrite this property."); } @@ -92,7 +86,7 @@ public void shouldSetUserAgentFromSystemProperty() { customConnector.createRequest().url("http://localhost:" + PORT).payload("test").execute(); // then - verify(postRequestedFor(urlEqualTo("/")).withHeader(HTTP.USER_AGENT, equalTo("foo"))); + verify(postRequestedFor(urlEqualTo("/")).withHeader(HttpHeaders.USER_AGENT, equalTo("foo"))); } } diff --git a/connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpConnectorTest.java b/connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpConnectorTest.java similarity index 92% rename from connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpConnectorTest.java rename to connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpConnectorTest.java index bcde688fd18..36cc99ab186 100644 --- a/connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpConnectorTest.java +++ b/connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpConnectorTest.java @@ -14,13 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.camunda.connect.soap.httpclient; +package org.camunda.connect.httpclient.soap; import static org.assertj.core.api.Assertions.assertThat; -import org.apache.http.client.methods.HttpPost; +import org.apache.hc.client5.http.classic.methods.HttpPost; import org.camunda.connect.Connectors; -import org.camunda.connect.httpclient.soap.SoapHttpConnector; import org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorImpl; import org.camunda.connect.impl.DebugRequestInterceptor; import org.camunda.connect.spi.Connector; diff --git a/connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpRequestTest.java b/connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpRequestTest.java similarity index 88% rename from connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpRequestTest.java rename to connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpRequestTest.java index e1ef43e77fa..0cd4fadbbf7 100644 --- a/connect/soap-http-client/src/test/java/org/camunda/connect/soap/httpclient/SoapHttpRequestTest.java +++ b/connect/soap-http-client/src/test/java/org/camunda/connect/httpclient/soap/SoapHttpRequestTest.java @@ -14,13 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.camunda.connect.soap.httpclient; +package org.camunda.connect.httpclient.soap; import static org.assertj.core.api.Assertions.assertThat; import org.camunda.connect.Connectors; -import org.camunda.connect.httpclient.soap.SoapHttpConnector; -import org.camunda.connect.httpclient.soap.SoapHttpRequest; import org.junit.Before; import org.junit.Test; diff --git a/distro/run/qa/integration-tests/pom.xml b/distro/run/qa/integration-tests/pom.xml index 0314a772f58..e6a91beb898 100644 --- a/distro/run/qa/integration-tests/pom.xml +++ b/distro/run/qa/integration-tests/pom.xml @@ -53,13 +53,6 @@ test - - - commons-logging - commons-logging - test - - org.camunda.bpm.qa @@ -82,7 +75,7 @@ org.apache.httpcomponents httpclient - ${version.httpclient} + 4.5.14 test @@ -127,4 +120,4 @@ - \ No newline at end of file + diff --git a/distro/run/qa/pom.xml b/distro/run/qa/pom.xml index eb9639af424..8eb1c36ead7 100644 --- a/distro/run/qa/pom.xml +++ b/distro/run/qa/pom.xml @@ -19,7 +19,7 @@ 1.15 1.15 - 4.5.10 + 5.3.1 4.13.1 112.0.5615.49 @@ -28,8 +28,8 @@ - org.apache.httpcomponents - httpcomponents-client + org.apache.httpcomponents.client5 + httpclient5-parent ${version.httpcomponents} pom import diff --git a/distro/run/qa/runtime/pom.xml b/distro/run/qa/runtime/pom.xml index 3da0c917616..1cddcc33e22 100644 --- a/distro/run/qa/runtime/pom.xml +++ b/distro/run/qa/runtime/pom.xml @@ -82,13 +82,6 @@ test - - - commons-logging - commons-logging - test - - org.camunda.bpm.qa @@ -109,8 +102,8 @@ - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 ${version.httpclient} test diff --git a/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/httpclient/main/module.xml b/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/client5/httpclient5/main/module.xml similarity index 67% rename from distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/httpclient/main/module.xml rename to distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/client5/httpclient5/main/module.xml index cfc5c4265ab..cf14395afe3 100644 --- a/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/httpclient/main/module.xml +++ b/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/client5/httpclient5/main/module.xml @@ -1,6 +1,6 @@ - + - + @@ -12,7 +12,7 @@ - + diff --git a/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/httpcore/main/module.xml b/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/core5/httpcore5/main/module.xml similarity index 79% rename from distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/httpcore/main/module.xml rename to distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/core5/httpcore5/main/module.xml index 2a32f9abcec..ec9956a0503 100644 --- a/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/httpcore/main/module.xml +++ b/distro/wildfly/modules/src/main/modules/org/apache/httpcomponents/core5/httpcore5/main/module.xml @@ -1,6 +1,6 @@ - + - + diff --git a/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml b/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml index fb5f1bc2401..a78cd5aae8b 100644 --- a/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml +++ b/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml @@ -10,6 +10,6 @@ - + diff --git a/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml b/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml index e5325ef4b5f..f0a3628c551 100644 --- a/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml +++ b/distro/wildfly/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml @@ -11,6 +11,6 @@ - + diff --git a/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/httpclient/main/module.xml b/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/client5/httpclient5/main/module.xml similarity index 62% rename from distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/httpclient/main/module.xml rename to distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/client5/httpclient5/main/module.xml index a60bf12f18a..fdbb5361851 100644 --- a/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/httpclient/main/module.xml +++ b/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/client5/httpclient5/main/module.xml @@ -1,6 +1,6 @@ - + - + @@ -10,7 +10,7 @@ - + diff --git a/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/httpcore/main/module.xml b/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/core5/httpcore5/main/module.xml similarity index 79% rename from distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/httpcore/main/module.xml rename to distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/core5/httpcore5/main/module.xml index 81b2ca0820d..ba5fc80980d 100644 --- a/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/httpcore/main/module.xml +++ b/distro/wildfly26/modules/src/main/modules/org/apache/httpcomponents/core5/httpcore5/main/module.xml @@ -1,6 +1,6 @@ - + - + diff --git a/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml b/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml index 7a8c668386c..1f652a133c4 100644 --- a/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml +++ b/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-http-client/main/module.xml @@ -10,6 +10,6 @@ - + diff --git a/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml b/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml index a8f2bf120c4..834685de0cb 100644 --- a/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml +++ b/distro/wildfly26/modules/src/main/modules/org/camunda/connect/camunda-connect-soap-http-client/main/module.xml @@ -11,6 +11,6 @@ - + diff --git a/engine-plugins/connect-plugin/src/test/java/org/camunda/connect/plugin/MockHttpConnectorConfigurator.java b/engine-plugins/connect-plugin/src/test/java/org/camunda/connect/plugin/MockHttpConnectorConfigurator.java index 622ab793f1f..25aab021f04 100644 --- a/engine-plugins/connect-plugin/src/test/java/org/camunda/connect/plugin/MockHttpConnectorConfigurator.java +++ b/engine-plugins/connect-plugin/src/test/java/org/camunda/connect/plugin/MockHttpConnectorConfigurator.java @@ -16,13 +16,11 @@ */ package org.camunda.connect.plugin; -import java.io.IOException; - -import org.apache.http.HttpVersion; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.message.BasicHttpResponse; import org.camunda.connect.httpclient.HttpConnector; import org.camunda.connect.httpclient.impl.HttpResponseImpl; import org.camunda.connect.spi.ConnectorConfigurator; @@ -59,14 +57,27 @@ public Class getConnectorClass() { return HttpConnector.class; } - static class TestHttpResonse extends BasicHttpResponse implements CloseableHttpResponse { + static class TestHttpResonse extends BasicHttpResponse implements ClassicHttpResponse { + + private HttpEntity entity; public TestHttpResonse() { - super(HttpVersion.HTTP_1_1, 200, "OK"); + super(200, "OK"); + } + + @Override + public HttpEntity getEntity() { + return entity; + } + + @Override + public void setEntity(HttpEntity entity) { + this.entity = entity; } - public void close() throws IOException { - // no-op + @Override + public void close() { + /* NOP */ } } diff --git a/engine-rest/engine-rest-jakarta/pom.xml b/engine-rest/engine-rest-jakarta/pom.xml index 3b0400b6ef1..90b0d316559 100644 --- a/engine-rest/engine-rest-jakarta/pom.xml +++ b/engine-rest/engine-rest-jakarta/pom.xml @@ -174,8 +174,8 @@ - org.apache.httpcomponents - httpcore + org.apache.httpcomponents.core5 + httpcore5 test diff --git a/engine-rest/engine-rest/pom.xml b/engine-rest/engine-rest/pom.xml index ad07e2004d3..9f48279e113 100644 --- a/engine-rest/engine-rest/pom.xml +++ b/engine-rest/engine-rest/pom.xml @@ -166,8 +166,8 @@ - org.apache.httpcomponents - httpcore + org.apache.httpcomponents.core5 + httpcore5 test @@ -354,8 +354,8 @@ test - httpclient - org.apache.httpcomponents + httpclient5 + org.apache.httpcomponents.client5 @@ -558,8 +558,8 @@ test - httpclient - org.apache.httpcomponents + httpclient5 + org.apache.httpcomponents.client5 diff --git a/engine-rest/engine-rest/src/test/java-resteasy/org/camunda/bpm/engine/rest/util/container/ResteasyTomcatServerBootstrap.java b/engine-rest/engine-rest/src/test/java-resteasy/org/camunda/bpm/engine/rest/util/container/ResteasyTomcatServerBootstrap.java index e955c4c0766..f67520431b5 100644 --- a/engine-rest/engine-rest/src/test/java-resteasy/org/camunda/bpm/engine/rest/util/container/ResteasyTomcatServerBootstrap.java +++ b/engine-rest/engine-rest/src/test/java-resteasy/org/camunda/bpm/engine/rest/util/container/ResteasyTomcatServerBootstrap.java @@ -35,7 +35,7 @@ protected void addRuntimeSpecificLibraries(WebArchive wa, PomEquippedResolveStag wa.addAsLibraries(resolver.addDependencies( MavenDependencies.createDependency("org.jboss.resteasy:resteasy-jaxrs:" + restEasyVersion, ScopeType.TEST, false, - MavenDependencies.createExclusion("org.apache.httpcomponents:httpclient"))).resolve() + MavenDependencies.createExclusion("org.apache.httpcomponents.client5:httpclient5"))).resolve() .withTransitivity().asFile()); } diff --git a/engine-rest/pom.xml b/engine-rest/pom.xml index be10c1fee38..3f6ecf0d100 100644 --- a/engine-rest/pom.xml +++ b/engine-rest/pom.xml @@ -17,7 +17,6 @@ 4.5.0 3.0.9 - 4.4.5 1.15 @@ -57,9 +56,9 @@ pom - org.apache.httpcomponents - httpcore - ${version.apache.httpcore} + org.apache.httpcomponents.core5 + httpcore5 + 5.2.4 commons-codec diff --git a/engine/pom.xml b/engine/pom.xml index 1b7a9f5b2c0..a6f08eeb1d9 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -495,8 +495,8 @@ org.mybatis:mybatis:* commons-logging:* joda-time:* - org.apache.httpcomponents:httpclient - org.apache.httpcomponents:httpcore + org.apache.httpcomponents.client5:httpclient5 + org.apache.httpcomponents.core5:httpcore5 commons-codec:commons-codec diff --git a/internal-dependencies/pom.xml b/internal-dependencies/pom.xml index 1b9c81e644a..ca2ba65c875 100644 --- a/internal-dependencies/pom.xml +++ b/internal-dependencies/pom.xml @@ -311,8 +311,8 @@ the exclusion here, please make sure to add it in the REST API projects --> - httpclient - org.apache.httpcomponents + httpclient5 + org.apache.httpcomponents.client5 commons-httpclient diff --git a/parent/pom.xml b/parent/pom.xml index 367add0e615..9385119aff2 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -42,7 +42,7 @@ 2.3.6 4.0.5 4.0.2 - 4.5.14 + 5.3.1 1.7.26 1.2.11 diff --git a/qa/integration-tests-webapps/integration-tests/pom.xml b/qa/integration-tests-webapps/integration-tests/pom.xml index dea754debc9..fb348b230b3 100644 --- a/qa/integration-tests-webapps/integration-tests/pom.xml +++ b/qa/integration-tests-webapps/integration-tests/pom.xml @@ -70,8 +70,8 @@ provided - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 provided diff --git a/qa/integration-tests-webapps/pom.xml b/qa/integration-tests-webapps/pom.xml index d9d017e108f..a71d8fcc327 100644 --- a/qa/integration-tests-webapps/pom.xml +++ b/qa/integration-tests-webapps/pom.xml @@ -55,9 +55,9 @@ - org.apache.httpcomponents - httpclient - 4.5.9 + org.apache.httpcomponents.client5 + httpclient5 + ${version.httpclient} @@ -139,8 +139,8 @@ - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 test diff --git a/spring-boot-starter/starter-qa/integration-test-webapp/runtime/pom.xml b/spring-boot-starter/starter-qa/integration-test-webapp/runtime/pom.xml index 313ee3241cb..0fe53df9cb3 100644 --- a/spring-boot-starter/starter-qa/integration-test-webapp/runtime/pom.xml +++ b/spring-boot-starter/starter-qa/integration-test-webapp/runtime/pom.xml @@ -81,8 +81,8 @@ - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 ${version.httpclient} test