build(deps): bump OkHttp from 2.4.0 to 2.7.5
build(deps): bump H2 from 1.3.173 to 1.4.200
MODIFY
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/HttpConnectorFactory.java
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/HttpConnectorFactory.java
@@ -35,16 +35,14 @@ import java.net.ProxySelector;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-
import javax.net.SocketFactory;
import com.squareup.okhttp.CertificatePinner;
import com.squareup.okhttp.ConnectionPool;
import com.squareup.okhttp.ConnectionSpec;
+import com.squareup.okhttp.Dns;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Protocol;
-import com.squareup.okhttp.internal.Internal;
-import com.squareup.okhttp.internal.Network;
import com.squareup.okhttp.internal.Util;
import com.squareup.okhttp.internal.http.AuthenticatorAdapter;
@@ -58,17 +56,18 @@ public class HttpConnectorFactory implements IConnectorFactory {
private static final List<ConnectionSpec> DEFAULT_CONNECTION_SPECS = Util.immutableList(
ConnectionSpec.MODERN_TLS, ConnectionSpec.COMPATIBLE_TLS, ConnectionSpec.CLEARTEXT);
- private OkHttpClient okClient;
+ private final OkHttpClient okClient;
// Standard auth
private SSLSessionStrategy standardSslStrategy;
// 2WAY auth (i.e. mutual auth)
private SSLSessionStrategy mutualAuthSslStrategy;
- private TLSOptions tlsOptions;
- private HttpConnectorOptions connectorOptions;
+ private final TLSOptions tlsOptions;
+ private final HttpConnectorOptions connectorOptions;
/**
* Constructor.
+ *
* @param config map of configuration options
*/
public HttpConnectorFactory(Map<String, String> config) {
@@ -95,13 +94,14 @@ public class HttpConnectorFactory implements IConnectorFactory {
client.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
client.setSocketFactory(SocketFactory.getDefault());
- Internal.instance.setNetwork(client, Network.DEFAULT);
+ client.setDns(Dns.SYSTEM);
return client;
}
/**
- * @see io.apiman.gateway.engine.IConnectorFactory#createConnector(io.apiman.gateway.engine.beans.ApiRequest, io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.auth.RequiredAuthType)
+ * @see io.apiman.gateway.engine.IConnectorFactory#createConnector(ApiRequest, Api, RequiredAuthType,
+ * boolean, IConnectorConfig)
*/
@Override
public IApiConnector createConnector(ApiRequest request, final Api api,
@@ -125,6 +125,7 @@ public class HttpConnectorFactory implements IConnectorFactory {
/**
* Creates the SSL strategy based on configured TLS options.
+ *
* @param authType
* @return an appropriate SSL strategy
*/

MODIFY
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/ok/HttpURLConnectionImpl.java
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/ok/HttpURLConnectionImpl.java
@@ -38,12 +38,9 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import okio.BufferedSink;
-import okio.Sink;
-
-import com.squareup.okhttp.Connection;
import com.squareup.okhttp.Handshake;
import com.squareup.okhttp.Headers;
+import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Protocol;
import com.squareup.okhttp.Request;
@@ -52,7 +49,6 @@ import com.squareup.okhttp.Response;
import com.squareup.okhttp.Route;
import com.squareup.okhttp.internal.Internal;
import com.squareup.okhttp.internal.Platform;
-import com.squareup.okhttp.internal.Util;
import com.squareup.okhttp.internal.http.HttpDate;
import com.squareup.okhttp.internal.http.HttpEngine;
import com.squareup.okhttp.internal.http.HttpMethod;
@@ -61,6 +57,9 @@ import com.squareup.okhttp.internal.http.RequestException;
import com.squareup.okhttp.internal.http.RetryableSink;
import com.squareup.okhttp.internal.http.RouteException;
import com.squareup.okhttp.internal.http.StatusLine;
+import com.squareup.okhttp.internal.http.StreamAllocation;
+import okio.BufferedSink;
+import okio.Sink;
/**
* This implementation uses HttpEngine to send requests and receive responses.
@@ -118,10 +117,10 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
}
@Override public final void disconnect() {
- // Calling disconnect() before a connection exists should have no effect.
+ // Calling cancel() before a connection exists should have no effect.
if (httpEngine == null) return;
- httpEngine.disconnect();
+ httpEngine.cancel();
// This doesn't close the stream because doing so would require all stream
// access to be synchronized. It's expected that the thread using the
@@ -256,9 +255,11 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
return sink.outputStream();
}
- @Override public final Permission getPermission() throws IOException {
+ @Override public final Permission getPermission() {
String hostName = getURL().getHost();
- int hostPort = Util.getEffectivePort(getURL());
+ int hostPort = url.getPort() != -1
+ ? url.getPort()
+ : HttpUrl.defaultPort(url.getProtocol());
if (usingProxy()) {
InetSocketAddress proxyAddress = (InetSocketAddress) client.getProxy().address();
hostName = proxyAddress.getHostName();
@@ -318,7 +319,7 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
}
}
- private HttpEngine newHttpEngine(String method, Connection connection,
+ private HttpEngine newHttpEngine(String method, StreamAllocation connection,
RetryableSink requestBody, Response priorResponse) {
// OkHttp's Call API requires a placeholder body; the real body will be streamed separately.
RequestBody placeholderBody = HttpMethod.requiresRequestBody(method)
@@ -361,8 +362,16 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
engineClient = client.clone().setCache(null);
}
- return new HttpEngine(engineClient, request, bufferRequestBody, true, false, connection, null,
- requestBody, priorResponse);
+ return new HttpEngine(
+ engineClient,
+ request,
+ bufferRequestBody,
+ true,
+ false,
+ connection,
+ requestBody,
+ priorResponse
+ );
}
private String defaultUserAgent() {
@@ -391,7 +400,7 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
Request followUp = httpEngine.followUpRequest();
if (followUp == null) {
- httpEngine.releaseConnection();
+ httpEngine.releaseStreamAllocation();
return httpEngine;
}
@@ -415,13 +424,12 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
throw new HttpRetryException("Cannot retry streamed HTTP body", responseCode);
}
- if (!httpEngine.sameConnection(followUp.url())) {
- httpEngine.releaseConnection();
+ if (!httpEngine.sameConnection(HttpUrl.get(followUp.url()))) {
+ httpEngine.releaseStreamAllocation();
}
- Connection connection = httpEngine.close();
- httpEngine = newHttpEngine(followUp.method(), connection, (RetryableSink) requestBody,
- response);
+ StreamAllocation connection = httpEngine.close();
+ httpEngine = newHttpEngine(followUp.method(), connection, (RetryableSink) requestBody, response);
}
}
@@ -433,7 +441,7 @@ public class HttpURLConnectionImpl extends HttpURLConnection {
private boolean execute(boolean readResponse) throws IOException {
try {
httpEngine.sendRequest();
- route = httpEngine.getRoute();
+ route = httpEngine.getConnection().getRoute();
handshake = httpEngine.getConnection() != null
? httpEngine.getConnection().getHandshake()
: null;

MODIFY
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/JdbcTestSuite.java
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/JdbcTestSuite.java
@@ -64,7 +64,7 @@ public class JdbcTestSuite {
*/
@BeforeClass
public static void setupH2() throws SQLException {
- h2Server = Server.createTcpServer().start();
+ h2Server = Server.createTcpServer("-ifNotExists").start();
}
@AfterClass

MODIFY
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/SpecHelpers.java
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/SpecHelpers.java
@@ -62,7 +62,7 @@ public interface SpecHelpers {
IJdbcClient client = component.createStandalone(options);
client.connect(explodeOnFailure(context, async, connectionResult -> {
- System.out.println("Successfully connected!");
+ System.out.println("Dropping everything in the DB!");
IJdbcConnection connection = connectionResult;
connection.execute(explodeOnFailure(context, async,
onSuccess -> {

MODIFY
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/suitetests/CreateTableTest.java
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/suitetests/CreateTableTest.java
@@ -66,7 +66,7 @@ public class CreateTableTest {
client.connect(explodeOnFailure(context, async, connectionResult -> {
System.out.println("Successfully connected!");
IJdbcConnection connection = connectionResult;
- String createTableSql = "create table APIMAN\n" +
+ String createTableSql = "create table APIMAN_FOO_BAR\n" +
" (PLACE_ID integer NOT NULL,\n" +
" COUNTRY varchar(40) NOT NULL,\n" +
" CITY varchar(20) NOT NULL,\n" +

MODIFY
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/suitetests/QueryTest.java
gateway/platforms/vertx3/vertx3/src/test/java/io/apiman/gateway/platforms/vertx3/components/jdbc/suitetests/QueryTest.java
@@ -79,7 +79,7 @@ public class QueryTest {
" BYTEARRAY varbinary(100) NOT NULL,\n" +
" PRIMARY KEY (ID));";
String insertSql = "insert into APIMAN (ID, STRING, SHORT, INTEGER, LONG, DOUBLE, BOOLEAN, DATETIME, BYTEARRAY)\n" +
- " VALUES (1, 'Voltigeur', 11, 9001009, 101010101, 3.14159, true, '1976-06-29 00:00:00', 31), ";
+ " VALUES (1, 'Voltigeur', 11, 9001009, 101010101, 3.14159, TRUE, '1976-06-29 00:00:00', 31); ";
connection.execute(
explodeOnFailure(context, async, onSuccess1 -> {
connection.execute(

MODIFY
pom.xml
pom.xml
<!-- Dependency Versions -->
<version.com.fasterxml.jackson>2.10.0</version.com.fasterxml.jackson>
- <version.com.h2database>1.3.173</version.com.h2database>
+ <version.com.h2database>1.4.200</version.com.h2database>
<version.com.lmax>3.4.2</version.com.lmax>
- <version.com.squareup.okhttp>2.4.0</version.com.squareup.okhttp>
+ <version.com.squareup.okhttp>2.7.5</version.com.squareup.okhttp>
<version.com.squareup.okio>1.4.0</version.com.squareup.okio>
<version.com.unboundid.unboundid-ldapsdk>5.1.3</version.com.unboundid.unboundid-ldapsdk>
<version.commons-beanutils>1.9.4</version.commons-beanutils>

build(deps): bump OkHttp from 2.4.0 to 2.7.5

build(deps): bump H2 from 1.3.173 to 1.4.200