Skip to content

Commit 822e481

Browse files
author
Josh Gordineer
committed
remove guava
1 parent a634f1d commit 822e481

64 files changed

Lines changed: 325 additions & 366 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ rx_java_version=1.0.9
22
rx_netty_version=0.4.9
33
servo_version=0.10.1
44
hystrix_version=1.4.3
5-
guava_version=19.0
65
archaius_version=0.7.6
76
eureka_version=1.7.2
87
jersey_version=1.19.1

ribbon-archaius/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
dependencies {
22
api "org.slf4j:slf4j-api:${slf4j_version}"
33
api 'com.google.code.findbugs:annotations:2.0.0'
4-
api "com.google.guava:guava:${guava_version}"
54
api 'commons-configuration:commons-configuration:1.8'
65
api 'commons-lang:commons-lang:2.6'
76
api "com.netflix.archaius:archaius-core:${archaius_version}"

ribbon-core/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
dependencies {
22
api "org.slf4j:slf4j-api:${slf4j_version}"
33
api 'com.google.code.findbugs:annotations:2.0.0'
4-
api "com.google.guava:guava:${guava_version}"
54
api 'commons-lang:commons-lang:2.6'
65

76
testImplementation 'junit:junit:4.11'

ribbon-core/src/main/java/com/netflix/client/DefaultLoadBalancerRetryHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
*/
1818
package com.netflix.client;
1919

20-
import com.google.common.collect.Lists;
2120
import com.netflix.client.config.CommonClientConfigKey;
2221
import com.netflix.client.config.IClientConfig;
2322

2423
import java.net.ConnectException;
2524
import java.net.SocketException;
2625
import java.net.SocketTimeoutException;
26+
import java.util.ArrayList;
27+
import java.util.Arrays;
2728
import java.util.List;
2829

2930
/**
@@ -36,12 +37,12 @@
3637
public class DefaultLoadBalancerRetryHandler implements RetryHandler {
3738

3839
@SuppressWarnings("unchecked")
39-
private List<Class<? extends Throwable>> retriable =
40-
Lists.<Class<? extends Throwable>>newArrayList(ConnectException.class, SocketTimeoutException.class);
40+
private List<Class<? extends Throwable>> retriable =
41+
new ArrayList<>(Arrays.asList(ConnectException.class, SocketTimeoutException.class));
4142

4243
@SuppressWarnings("unchecked")
4344
private List<Class<? extends Throwable>> circuitRelated =
44-
Lists.<Class<? extends Throwable>>newArrayList(SocketException.class, SocketTimeoutException.class);
45+
new ArrayList<>(Arrays.asList(SocketException.class, SocketTimeoutException.class));
4546

4647
protected final int retrySameServer;
4748
protected final int retryNextServer;

ribbon-core/src/main/java/com/netflix/client/RequestSpecificRetryHandler.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package com.netflix.client;
22

3-
import com.google.common.base.Preconditions;
4-
import com.google.common.collect.Lists;
53
import com.netflix.client.config.CommonClientConfigKey;
64
import com.netflix.client.config.IClientConfig;
75

8-
import javax.annotation.Nullable;
6+
import java.util.Collections;
7+
import java.util.Objects;
98
import java.net.SocketException;
109
import java.util.List;
11-
import java.util.Optional;
10+
import javax.annotation.Nullable;
1211

1312
/**
1413
* Implementation of RetryHandler created for each request which allows for request
@@ -22,15 +21,15 @@ public class RequestSpecificRetryHandler implements RetryHandler {
2221
private final boolean okToRetryOnConnectErrors;
2322
private final boolean okToRetryOnAllErrors;
2423

25-
protected List<Class<? extends Throwable>> connectionRelated =
26-
Lists.<Class<? extends Throwable>>newArrayList(SocketException.class);
24+
protected List<Class<? extends Throwable>> connectionRelated =
25+
Collections.singletonList(SocketException.class);
2726

2827
public RequestSpecificRetryHandler(boolean okToRetryOnConnectErrors, boolean okToRetryOnAllErrors) {
2928
this(okToRetryOnConnectErrors, okToRetryOnAllErrors, RetryHandler.DEFAULT, null);
3029
}
3130

3231
public RequestSpecificRetryHandler(boolean okToRetryOnConnectErrors, boolean okToRetryOnAllErrors, RetryHandler baseRetryHandler, @Nullable IClientConfig requestConfig) {
33-
Preconditions.checkNotNull(baseRetryHandler);
32+
Objects.requireNonNull(baseRetryHandler);
3433
this.okToRetryOnConnectErrors = okToRetryOnConnectErrors;
3534
this.okToRetryOnAllErrors = okToRetryOnAllErrors;
3635
this.fallback = baseRetryHandler;

ribbon-core/src/main/java/com/netflix/client/config/CommonClientConfigKey.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package com.netflix.client.config;
1919

20-
import com.google.common.reflect.TypeToken;
21-
2220
import java.lang.reflect.Field;
2321
import java.lang.reflect.Modifier;
2422
import java.lang.reflect.ParameterizedType;
@@ -28,8 +26,6 @@
2826
import java.util.Set;
2927
import java.util.concurrent.TimeUnit;
3028

31-
import static com.google.common.base.Preconditions.checkArgument;
32-
3329
public abstract class CommonClientConfigKey<T> implements IClientConfigKey<T> {
3430

3531
public static final String DEFAULT_NAME_SPACE = "ribbon";
@@ -248,20 +244,20 @@ public Class type() {
248244

249245
private final String configKey;
250246
private final Class<T> type;
251-
private T defaultValue;
247+
private final T defaultValue;
252248

253-
@SuppressWarnings("unchecked")
254249
protected CommonClientConfigKey(String configKey) {
255250
this(configKey, null);
256251
}
257252

253+
@SuppressWarnings("unchecked")
258254
protected CommonClientConfigKey(String configKey, T defaultValue) {
259255
this.configKey = configKey;
260256
Type superclass = getClass().getGenericSuperclass();
261-
checkArgument(superclass instanceof ParameterizedType,
262-
"%s isn't parameterized", superclass);
263-
Type runtimeType = ((ParameterizedType) superclass).getActualTypeArguments()[0];
264-
type = (Class<T>) TypeToken.of(runtimeType).getRawType();
257+
if (!(superclass instanceof ParameterizedType)) {
258+
throw new IllegalArgumentException(superclass + " isn't parameterized");
259+
}
260+
this.type = (Class<T>) ((ParameterizedType) superclass).getActualTypeArguments()[0];
265261
this.defaultValue = defaultValue;
266262
}
267263

ribbon-core/src/main/java/com/netflix/client/config/ReloadableClientConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.netflix.client.config;
22

3-
import com.google.common.base.Preconditions;
3+
import java.util.Objects;
44
import org.apache.commons.lang.StringUtils;
55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
@@ -159,7 +159,7 @@ interface ReloadableProperty<T> extends Property<T> {
159159
}
160160

161161
private synchronized <T> Property<T> getOrCreateProperty(final IClientConfigKey<T> key, final Supplier<Optional<T>> valueSupplier, final Supplier<T> defaultSupplier) {
162-
Preconditions.checkNotNull(valueSupplier, "defaultValueSupplier cannot be null");
162+
Objects.requireNonNull(valueSupplier, "defaultValueSupplier cannot be null");
163163

164164
return (Property<T>)dynamicProperties.computeIfAbsent(key, ignore -> new ReloadableProperty<T>() {
165165
private volatile Optional<T> current = Optional.empty();
@@ -355,7 +355,7 @@ protected final <T> void setDefault(IClientConfigKey<T> key) {
355355
* Store the default value for key while giving precedence to default values in the property resolver
356356
*/
357357
protected final <T> void setDefault(IClientConfigKey<T> key, T value) {
358-
Preconditions.checkArgument(key != null, "key cannot be null");
358+
Objects.requireNonNull(key, "key cannot be null");
359359

360360
value = resolveFromPropertyResolver(key).orElse(value);
361361
internalProperties.put(key, Optional.ofNullable(value));
@@ -367,7 +367,7 @@ protected final <T> void setDefault(IClientConfigKey<T> key, T value) {
367367

368368
@Override
369369
public <T> IClientConfig set(IClientConfigKey<T> key, T value) {
370-
Preconditions.checkArgument(key != null, "key cannot be null");
370+
Objects.requireNonNull(key, "key cannot be null");
371371

372372
value = resolveValueToType(key, value);
373373
if (isDynamic) {
@@ -384,7 +384,7 @@ public <T> IClientConfig set(IClientConfigKey<T> key, T value) {
384384
@Override
385385
@Deprecated
386386
public void setProperty(IClientConfigKey key, Object value) {
387-
Preconditions.checkArgument(value != null, "Value may not be null");
387+
Objects.requireNonNull(value, "Value may not be null");
388388
set(key, value);
389389
}
390390

ribbon-core/src/main/java/com/netflix/client/ssl/URLSslContextFactory.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
import org.slf4j.Logger;
3030
import org.slf4j.LoggerFactory;
3131

32-
import com.google.common.base.Preconditions;
33-
import com.google.common.base.Strings;
34-
3532
/**
3633
* Secure socket factory that is used the NIWS code if a non-standard key store or trust store
3734
* is specified.
@@ -100,8 +97,11 @@ private static KeyStore createKeyStore(final URL storeFile, final String passwor
10097
if(storeFile == null){
10198
return null;
10299
}
103-
104-
Preconditions.checkArgument(StringUtils.isNotEmpty(password), "Null keystore should have empty password, defined keystore must have password");
100+
101+
if (StringUtils.isEmpty(password)) {
102+
throw new IllegalArgumentException(
103+
"Null keystore should have empty password, defined keystore must have password");
104+
}
105105

106106
KeyStore keyStore = null;
107107

@@ -139,13 +139,17 @@ public String toString() {
139139

140140
builder.append("ClientSslSocketFactory [trustStoreUrl=").append(trustStoreUrl);
141141
if (trustStoreUrl != null) {
142-
builder.append(", trustStorePassword=");
143-
builder.append(Strings.repeat("*", this.getTrustStorePasswordLength()));
142+
builder.append(", trustStorePassword=");
143+
for (int i = 0; i < this.getTrustStorePasswordLength(); i++) {
144+
builder.append("*");
145+
}
144146
}
145147
builder.append(", keyStoreUrl=").append(keyStoreUrl);
146148
if (keyStoreUrl != null) {
147149
builder.append(", keystorePassword = ");
148-
builder.append(Strings.repeat("*", this.getKeyStorePasswordLength()));
150+
for (int i = 0; i < this.getKeyStorePasswordLength(); i++) {
151+
builder.append("*");
152+
}
149153
}
150154
builder.append(']');
151155

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.netflix.client.util;
2+
3+
import java.util.concurrent.Executors;
4+
import java.util.concurrent.ThreadFactory;
5+
6+
public class ThreadUtils {
7+
8+
public static ThreadFactory threadFactory(String name) {
9+
return r -> {
10+
Thread thread = Executors.defaultThreadFactory().newThread(r);
11+
thread.setName(name);
12+
thread.setDaemon(true);
13+
return thread;
14+
};
15+
}
16+
}

ribbon-core/src/test/java/com/netflix/client/config/CommonClientConfigKeyTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
import static org.junit.Assert.*;
44

5+
56
import org.junit.Test;
67

7-
import com.google.common.collect.Sets;
8+
import java.util.Arrays;
9+
import java.util.HashSet;
810

911
public class CommonClientConfigKeyTest {
1012

1113
@Test
1214
public void testCommonKeys() {
1315
IClientConfigKey[] keys = CommonClientConfigKey.values();
1416
assertTrue(keys.length > 30);
15-
assertEquals(Sets.newHashSet(keys), CommonClientConfigKey.keys());
17+
assertEquals(new HashSet<>(Arrays.asList(keys)), CommonClientConfigKey.keys());
1618
assertTrue(CommonClientConfigKey.keys().contains(CommonClientConfigKey.ConnectTimeout));
1719
}
1820
}

0 commit comments

Comments
 (0)