diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java index 5c8c9c36..92476ff1 100644 --- a/client/src/main/java/io/split/client/SplitClientConfig.java +++ b/client/src/main/java/io/split/client/SplitClientConfig.java @@ -1053,9 +1053,18 @@ private void verifyEndPoints() { } } - public SplitClientConfig build() { - verifyRates(); + private void verifyAuthScheme() { + if (_authScheme == HttpAuthScheme.KERBEROS) { + if (proxy() == null) { + throw new IllegalStateException("Kerberos mode require Proxy parameters."); + } + if (_kerberosPrincipalName == null) { + throw new IllegalStateException("Kerberos mode require Kerberos Principal Name."); + } + } + } + private void verifyAllModes() { switch (_impressionsMode) { case OPTIMIZED: _impressionsRefreshRate = (_impressionsRefreshRate <= 0) ? 300 : Math.max(60, _impressionsRefreshRate); @@ -1068,7 +1077,19 @@ public SplitClientConfig build() { if (_impressionsQueueSize <=0 ) { throw new IllegalArgumentException("impressionsQueueSize must be > 0: " + _impressionsQueueSize); } + if(_storageMode == null) { + _storageMode = StorageMode.MEMORY; + } + if(OperationMode.CONSUMER.equals(_operationMode)){ + if(_customStorageWrapper == null) { + throw new IllegalStateException("Custom Storage must not be null on Consumer mode."); + } + _storageMode = StorageMode.PLUGGABLE; + } + } + + private void verifyNetworkParams() { if (_connectionTimeout <= 0) { throw new IllegalArgumentException("connectionTimeOutInMs must be > 0: " + _connectionTimeout); } @@ -1076,13 +1097,6 @@ public SplitClientConfig build() { if (_readTimeout <= 0) { throw new IllegalArgumentException("readTimeout must be > 0: " + _readTimeout); } - - verifyEndPoints(); - - if (_numThreadsForSegmentFetch <= 0) { - throw new IllegalArgumentException("Number of threads for fetching segments MUST be greater than zero"); - } - if (_authRetryBackoffBase <= 0) { throw new IllegalArgumentException("authRetryBackoffBase: must be >= 1"); } @@ -1098,27 +1112,23 @@ public SplitClientConfig build() { if(_onDemandFetchMaxRetries <= 0) { throw new IllegalStateException("_onDemandFetchMaxRetries must be > 0"); } + } + public SplitClientConfig build() { - if(_storageMode == null) { - _storageMode = StorageMode.MEMORY; - } + verifyRates(); - if(OperationMode.CONSUMER.equals(_operationMode)){ - if(_customStorageWrapper == null) { - throw new IllegalStateException("Custom Storage must not be null on Consumer mode."); - } - _storageMode = StorageMode.PLUGGABLE; - } + verifyAllModes(); - if (_authScheme == HttpAuthScheme.KERBEROS) { - if (proxy() == null) { - throw new IllegalStateException("Kerberos mode require Proxy parameters."); - } - if (_kerberosPrincipalName == null) { - throw new IllegalStateException("Kerberos mode require Kerberos Principal Name."); - } + verifyEndPoints(); + + verifyNetworkParams(); + + if (_numThreadsForSegmentFetch <= 0) { + throw new IllegalArgumentException("Number of threads for fetching segments MUST be greater than zero"); } + verifyAuthScheme(); + return new SplitClientConfig( _endpoint, _eventsEndpoint, diff --git a/client/src/main/java/io/split/service/HTTPKerberosAuthInterceptor.java b/client/src/main/java/io/split/service/HTTPKerberosAuthInterceptor.java index a11f9db9..8acd6618 100644 --- a/client/src/main/java/io/split/service/HTTPKerberosAuthInterceptor.java +++ b/client/src/main/java/io/split/service/HTTPKerberosAuthInterceptor.java @@ -175,7 +175,6 @@ private static class CreateAuthorizationHeaderAction implements PrivilegedAction String clientPrincipalName; String serverPrincipalName; -// private StringBuffer outputToken = new StringBuffer(); private StringBuilder outputToken = new StringBuilder(); private CreateAuthorizationHeaderAction(final String clientPrincipalName, final String serverPrincipalName) {