From 0101f001e62367ed2b24f546300ec14d5528afaa Mon Sep 17 00:00:00 2001 From: Patricio Echague Date: Fri, 4 Jun 2021 09:51:01 -0700 Subject: [PATCH 01/11] add setting to revalidate stale connections --- client/CHANGES.txt | 3 +++ client/pom.xml | 4 ++-- .../io/split/client/SplitClientConfig.java | 23 +++++++++++++++++-- .../io/split/client/SplitFactoryImpl.java | 11 +++++---- pom.xml | 2 +- testing/pom.xml | 2 +- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/client/CHANGES.txt b/client/CHANGES.txt index e02d816d8..278ecaee1 100644 --- a/client/CHANGES.txt +++ b/client/CHANGES.txt @@ -1,5 +1,8 @@ CHANGES +4.1.7 (Apr 15, 2021) +- add validateAfterInactivityInMillis to config to help with stale connection handling + 4.1.6 (Apr 15, 2021) -Updated log level and message in some messages. diff --git a/client/pom.xml b/client/pom.xml index 5336cf310..f89d6d089 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.1.6 + 4.1.7-rc1 java-client jar @@ -171,7 +171,7 @@ org.slf4j slf4j-log4j12 1.7.21 - test + org.glassfish.jersey.media diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java index cafd52ebb..c3a8bd45a 100644 --- a/client/src/main/java/io/split/client/SplitClientConfig.java +++ b/client/src/main/java/io/split/client/SplitClientConfig.java @@ -46,6 +46,7 @@ public class SplitClientConfig { private final int _streamingReconnectBackoffBase; private final String _authServiceURL; private final String _streamingServiceURL; + private long _validateAfterInactivityInMillis; // Proxy configs private final HttpHost _proxy; @@ -89,7 +90,8 @@ private SplitClientConfig(String endpoint, int authRetryBackoffBase, int streamingReconnectBackoffBase, String authServiceURL, - String streamingServiceURL) { + String streamingServiceURL, + long validateAfterInactivityInMillis) { _endpoint = endpoint; _eventsEndpoint = eventsEndpoint; _featuresRefreshRate = pollForFeatureChangesEveryNSeconds; @@ -120,6 +122,7 @@ private SplitClientConfig(String endpoint, _streamingReconnectBackoffBase = streamingReconnectBackoffBase; _authServiceURL = authServiceURL; _streamingServiceURL = streamingServiceURL; + _validateAfterInactivityInMillis = validateAfterInactivityInMillis; Properties props = new Properties(); try { @@ -248,6 +251,10 @@ public String streamingServiceURL() { return _streamingServiceURL; } + public long validateAfterInactivityInMillis() { + return _validateAfterInactivityInMillis; + } + public static final class Builder { private String _endpoint = "https://sdk.split.io"; @@ -283,6 +290,7 @@ public static final class Builder { private int _streamingReconnectBackoffBase = 1; private String _authServiceURL = "https://auth.split.io/api/auth"; private String _streamingServiceURL = "https://streaming.split.io/sse"; + private long _validateAfterInactivityInMillis = -1; public Builder() { } @@ -674,6 +682,16 @@ public Builder streamingServiceURL(String streamingServiceURL) { return this; } + /** + * Set the time after which period of inactivity a connection must be revalidated . + * @param validateAfterInactivityInMillis + * @return + */ + public Builder validateAfterInactivityInMillis(long validateAfterInactivityInMillis) { + _validateAfterInactivityInMillis = validateAfterInactivityInMillis; + return this; + } + public SplitClientConfig build() { if (_featuresRefreshRate < 5 ) { throw new IllegalArgumentException("featuresRefreshRate must be >= 5: " + _featuresRefreshRate); @@ -774,7 +792,8 @@ public SplitClientConfig build() { _authRetryBackoffBase, _streamingReconnectBackoffBase, _authServiceURL, - _streamingServiceURL); + _streamingServiceURL, + _validateAfterInactivityInMillis); } } } diff --git a/client/src/main/java/io/split/client/SplitFactoryImpl.java b/client/src/main/java/io/split/client/SplitFactoryImpl.java index 8b576d0dd..41c615c8c 100644 --- a/client/src/main/java/io/split/client/SplitFactoryImpl.java +++ b/client/src/main/java/io/split/client/SplitFactoryImpl.java @@ -43,6 +43,7 @@ import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.http.ssl.TLS; import org.apache.hc.core5.ssl.SSLContexts; +import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.Timeout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -210,7 +211,7 @@ private static CloseableHttpClient buildHttpClient(String apiToken, SplitClientC SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create() .setSslContext(SSLContexts.createSystemDefault()) - .setTlsVersions(TLS.V_1_1, TLS.V_1_2) + .setTlsVersions(TLS.V_1_2) .build(); RequestConfig requestConfig = RequestConfig.custom() @@ -223,9 +224,11 @@ private static CloseableHttpClient buildHttpClient(String apiToken, SplitClientC .setDefaultSocketConfig(SocketConfig.custom() .setSoTimeout(Timeout.ofMilliseconds(config.readTimeout())) .build()) + .setValidateAfterInactivity(TimeValue.ofMilliseconds(config.validateAfterInactivityInMillis())) + .setConnectionTimeToLive(TimeValue.ofMilliseconds(2000)) .build(); - cm.setMaxTotal(20); - cm.setDefaultMaxPerRoute(20); + cm.setMaxTotal(2); + cm.setDefaultMaxPerRoute(2); HttpClientBuilder httpClientbuilder = HttpClients.custom() .setConnectionManager(cm) @@ -249,7 +252,7 @@ private static CloseableHttpClient buildSSEdHttpClient(SplitClientConfig config) SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create() .setSslContext(SSLContexts.createSystemDefault()) - .setTlsVersions(TLS.V_1_1, TLS.V_1_2) + .setTlsVersions(TLS.V_1_2) .build(); PoolingHttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create() diff --git a/pom.xml b/pom.xml index 1a40cb3c5..97eb1deb1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.1.6 + 4.1.7-rc1 diff --git a/testing/pom.xml b/testing/pom.xml index 3d74dc7a8..af974473c 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -6,7 +6,7 @@ io.split.client java-client-parent - 4.1.6 + 4.1.7-rc1 java-client-testing From f5d4ec44cfb3ce71d959f4d3bbc0508c8a56b66f Mon Sep 17 00:00:00 2001 From: Patricio Echague Date: Fri, 4 Jun 2021 09:58:38 -0700 Subject: [PATCH 02/11] Fix mistakes --- client/src/main/java/io/split/client/SplitFactoryImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/main/java/io/split/client/SplitFactoryImpl.java b/client/src/main/java/io/split/client/SplitFactoryImpl.java index 41c615c8c..b46b4e681 100644 --- a/client/src/main/java/io/split/client/SplitFactoryImpl.java +++ b/client/src/main/java/io/split/client/SplitFactoryImpl.java @@ -225,10 +225,9 @@ private static CloseableHttpClient buildHttpClient(String apiToken, SplitClientC .setSoTimeout(Timeout.ofMilliseconds(config.readTimeout())) .build()) .setValidateAfterInactivity(TimeValue.ofMilliseconds(config.validateAfterInactivityInMillis())) - .setConnectionTimeToLive(TimeValue.ofMilliseconds(2000)) .build(); - cm.setMaxTotal(2); - cm.setDefaultMaxPerRoute(2); + cm.setMaxTotal(20); + cm.setDefaultMaxPerRoute(20); HttpClientBuilder httpClientbuilder = HttpClients.custom() .setConnectionManager(cm) From 026abef90d2251ae317ddd46b280757bfaf53ec3 Mon Sep 17 00:00:00 2001 From: Patricio Echague Date: Fri, 4 Jun 2021 10:12:18 -0700 Subject: [PATCH 03/11] Remove TLS 1.1 from the target list in the connection manager --- client/CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/client/CHANGES.txt b/client/CHANGES.txt index 278ecaee1..b0410a7e3 100644 --- a/client/CHANGES.txt +++ b/client/CHANGES.txt @@ -2,6 +2,7 @@ CHANGES 4.1.7 (Apr 15, 2021) - add validateAfterInactivityInMillis to config to help with stale connection handling +- Remove TLS 1.1 from the target list 4.1.6 (Apr 15, 2021) -Updated log level and message in some messages. From 1ad23f231a13f4a55b610fc80c7f485b41b79e1b Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 4 Jun 2021 16:25:38 -0300 Subject: [PATCH 04/11] Changing version --- client/pom.xml | 2 +- pom.xml | 2 +- testing/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index f89d6d089..981a0fad2 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.1.7-rc1 + 4.1.8-rc1 java-client jar diff --git a/pom.xml b/pom.xml index 97eb1deb1..aed1329bf 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.1.7-rc1 + 4.1.8-rc1 diff --git a/testing/pom.xml b/testing/pom.xml index af974473c..bbadf897f 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -6,7 +6,7 @@ io.split.client java-client-parent - 4.1.7-rc1 + 4.1.8-rc1 java-client-testing From 96a2cc3603ba3747d1643b52039ce20617b66995 Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 4 Jun 2021 17:24:20 -0300 Subject: [PATCH 05/11] Changes.txt --- client/CHANGES.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/CHANGES.txt b/client/CHANGES.txt index b0410a7e3..e02d816d8 100644 --- a/client/CHANGES.txt +++ b/client/CHANGES.txt @@ -1,9 +1,5 @@ CHANGES -4.1.7 (Apr 15, 2021) -- add validateAfterInactivityInMillis to config to help with stale connection handling -- Remove TLS 1.1 from the target list - 4.1.6 (Apr 15, 2021) -Updated log level and message in some messages. From 7ee3bda10a2ffcf6468e4ccae34349bb58e5091e Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 4 Jun 2021 17:49:24 -0300 Subject: [PATCH 06/11] Uncomment test scope --- client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pom.xml b/client/pom.xml index 981a0fad2..29a7a96fc 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -171,7 +171,7 @@ org.slf4j slf4j-log4j12 1.7.21 - + test org.glassfish.jersey.media From 13b5dbb47d108a7c29ad18e556817b0c8b6d869f Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 4 Jun 2021 18:11:51 -0300 Subject: [PATCH 07/11] Try testing app --- client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pom.xml b/client/pom.xml index 29a7a96fc..0be5ac43c 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -171,7 +171,7 @@ org.slf4j slf4j-log4j12 1.7.21 - test + test org.glassfish.jersey.media From d98c26ecf4bbd4158621d09510960ffb3de62cab Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 18 Jun 2021 12:36:40 -0300 Subject: [PATCH 08/11] Merge branch 'development' of github.com:splitio/java-client into revalidate-stale-connections # Conflicts: # client/pom.xml # client/src/main/java/io/split/client/SplitClientConfig.java # pom.xml # testing/pom.xml --- .../java/io/split/client/SplitClientConfig.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java index 124e9ef7e..6ab7981fb 100644 --- a/client/src/main/java/io/split/client/SplitClientConfig.java +++ b/client/src/main/java/io/split/client/SplitClientConfig.java @@ -291,6 +291,7 @@ public int get_telemetryRefreshRate() { public long validateAfterInactivityInMillis() { return _validateAfterInactivityInMillis; + } public static final class Builder { @@ -328,12 +329,12 @@ public static final class Builder { private String _authServiceURL = AUTH_ENDPOINT; private String _streamingServiceURL = STREAMING_ENDPOINT; private String _telemetryURl = TELEMETRY_ENDPOINT; - private int _telemetryRefreshRate = 60; + private int _telemetryRefreshRate = 3600; private int _onDemandFetchRetryDelayMs = 50; private final int _onDemandFetchMaxRetries = 10; private final int _failedAttemptsBeforeLogging = 10; private final boolean _cdnDebugLogging = true; - private long _validateAfterInactivityInMillis = -1; + private long _validateAfterInactivityInMillis = 500; public Builder() { } @@ -725,7 +726,7 @@ public Builder streamingServiceURL(String streamingServiceURL) { return this; } - * Set telemetry service URL. + /** Set telemetry service URL. * @param telemetryURL * @return */ @@ -752,6 +753,8 @@ public Builder telemetryRefreshRate(int telemetryRefreshRate) { */ public Builder validateAfterInactivityInMillis(long validateAfterInactivityInMillis) { _validateAfterInactivityInMillis = validateAfterInactivityInMillis; + return this; + } public SplitClientConfig build() { if (_featuresRefreshRate < 5 ) { @@ -830,10 +833,15 @@ public SplitClientConfig build() { if (_onDemandFetchRetryDelayMs <= 0) { throw new IllegalStateException("streamingRetryDelay must be > 0"); } + if(_onDemandFetchMaxRetries <= 0) { throw new IllegalStateException("_onDemandFetchMaxRetries must be > 0"); } + if(_telemetryRefreshRate <= 60) { + throw new IllegalStateException("_telemetryRefreshRate must be >= 60"); + } + return new SplitClientConfig( _endpoint, _eventsEndpoint, From 82a2b90878a8a565970c10ece519370ba9e9d3fa Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 18 Jun 2021 12:37:52 -0300 Subject: [PATCH 09/11] fixing space --- client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/pom.xml b/client/pom.xml index 602a339da..15019f068 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -171,7 +171,7 @@ org.slf4j slf4j-log4j12 1.7.21 - test + test org.glassfish.jersey.media From 874f8ea1e4da883413c1a6d0235ea90517e38ba2 Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 18 Jun 2021 13:12:06 -0300 Subject: [PATCH 10/11] Adding back TLS 1.1v --- client/src/main/java/io/split/client/SplitFactoryImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/io/split/client/SplitFactoryImpl.java b/client/src/main/java/io/split/client/SplitFactoryImpl.java index 1079306eb..eca563c84 100644 --- a/client/src/main/java/io/split/client/SplitFactoryImpl.java +++ b/client/src/main/java/io/split/client/SplitFactoryImpl.java @@ -246,7 +246,7 @@ public boolean isDestroyed() { private static CloseableHttpClient buildHttpClient(String apiToken, SplitClientConfig config) { SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create() .setSslContext(SSLContexts.createSystemDefault()) - .setTlsVersions(TLS.V_1_2) + .setTlsVersions(TLS.V_1_1, TLS.V_1_2) .build(); RequestConfig requestConfig = RequestConfig.custom() @@ -287,7 +287,7 @@ private static CloseableHttpClient buildSSEdHttpClient(String apiToken, SplitCli SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create() .setSslContext(SSLContexts.createSystemDefault()) - .setTlsVersions(TLS.V_1_2) + .setTlsVersions(TLS.V_1_1, TLS.V_1_2) .build(); PoolingHttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create() From 712b08a8145b10aea05d51b13449d19ccc18edbe Mon Sep 17 00:00:00 2001 From: Lucas Echeverz Date: Fri, 18 Jun 2021 15:43:45 -0300 Subject: [PATCH 11/11] Setting new default time, removing access to edit it. --- .../main/java/io/split/client/SplitClientConfig.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java index 6ab7981fb..d76bd57b9 100644 --- a/client/src/main/java/io/split/client/SplitClientConfig.java +++ b/client/src/main/java/io/split/client/SplitClientConfig.java @@ -334,7 +334,7 @@ public static final class Builder { private final int _onDemandFetchMaxRetries = 10; private final int _failedAttemptsBeforeLogging = 10; private final boolean _cdnDebugLogging = true; - private long _validateAfterInactivityInMillis = 500; + private long _validateAfterInactivityInMillis = 1000; public Builder() { } @@ -746,16 +746,6 @@ public Builder telemetryRefreshRate(int telemetryRefreshRate) { return this; } - /** - * Set the time after which period of inactivity a connection must be revalidated . - * @param validateAfterInactivityInMillis - * @return - */ - public Builder validateAfterInactivityInMillis(long validateAfterInactivityInMillis) { - _validateAfterInactivityInMillis = validateAfterInactivityInMillis; - return this; - } - public SplitClientConfig build() { if (_featuresRefreshRate < 5 ) { throw new IllegalArgumentException("featuresRefreshRate must be >= 5: " + _featuresRefreshRate);