Permalink
Browse files

SI-8116 Signifcantly reduce the dependency on Guava. Only data-avro a…

…nd restli-int-test subproject now depend on Guava.

RB=1396146
BUG=SI-8116
R=kbalasub,ajing,aponniah,xma,mlamure,mapatel
A=kbalasub,aponniah,xma
  • Loading branch information...
Baron Roberts
Baron Roberts committed Aug 20, 2018
1 parent 0ac6da1 commit 54048315cd6c6be8672bb678bae4c89e7eed1a42
Showing with 76 additions and 80 deletions.
  1. +5 −0 CHANGELOG
  2. +15 −5 build.gradle
  3. +0 −2 d2/src/main/java/com/linkedin/d2/balancer/clients/RewriteClient.java
  4. +0 −2 d2/src/main/java/com/linkedin/d2/balancer/clients/RewriteLoadBalancerClient.java
  5. +0 −2 d2/src/main/java/com/linkedin/d2/balancer/simple/SimpleLoadBalancer.java
  6. +1 −0 data-avro/build.gradle
  7. +4 −2 data-avro/src/main/java/com/linkedin/data/avro/SchemaToAvroJsonEncoder.java
  8. +6 −13 data-avro/src/test/java/com/linkedin/data/avro/TestDataTranslator.java
  9. +0 −1 data/build.gradle
  10. +13 −17 data/src/main/java/com/linkedin/data/schema/validator/DataSchemaAnnotationValidator.java
  11. +1 −1 gradle.properties
  12. +0 −1 multipart-mime/build.gradle
  13. +5 −4 multipart-mime/src/test/java/com/linkedin/multipart/TestMIMEWriter.java
  14. +5 −5 multipart-mime/src/test/java/com/linkedin/multipart/integ/TestMIMEIntegrationReaderWriter.java
  15. +7 −9 multipart-mime/src/test/java/com/linkedin/multipart/utils/MIMETestUtils.java
  16. +4 −2 restli-common/src/main/java/com/linkedin/restli/common/util/ProjectionMaskApplier.java
  17. +0 −1 restli-int-test-server/build.gradle
  18. +3 −2 ...src/main/java/com/linkedin/restli/examples/greetings/server/CustomMetadataProjectionResource.java
  19. +2 −2 ...er/src/main/java/com/linkedin/restli/examples/groups/server/rest/impl/GroupContactsResource2.java
  20. +1 −2 ...st-server/src/main/java/com/linkedin/restli/examples/groups/server/rest/impl/GroupsResource2.java
  21. +2 −4 restli-server/src/main/java/com/linkedin/restli/internal/server/ResourceContextImpl.java
  22. +0 −1 restli-tools/build.gradle
  23. +2 −2 restli-tools/src/test/java/com/linkedin/restli/tools/data/TestSchemaFormatTranslator.java
View
@@ -1,7 +1,12 @@
23.0.16
-------
23.0.15
-------
(RB=1394375)
Populate internal DataMap for gathered batch response.
(RB=1396146)
Remove Guava dependency from compile in all modules except data-avro and restli-int-test
(RB=1396585)
Updated gradle wrapper to version 4.6.
View
@@ -147,8 +147,7 @@ subprojects {
apply plugin: 'eclipse'
afterEvaluate {
if (project.plugins.hasPlugin('pegasus'))
{
if (project.plugins.hasPlugin('pegasus')) {
configurations {
pluginsRuntime {
visible = false
@@ -165,9 +164,7 @@ subprojects {
pegasusPlugin project(':generator')
pegasusPlugin project(':restli-tools')
}
}
else
{
} else {
apply from: "${buildScriptDirPath}/cleanGenerated.gradle", to: it
}
}
@@ -191,6 +188,19 @@ subprojects {
configurations.testArtifacts.visible = true
}
if (!(it.name in ['data-avro', 'restli-int-test'])) {
configurations {
// Prevent Guava from creeping in to avoid incompatibilities in multiple classloader environments.
compile.resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.google.guava' && details.requested.name == 'guava') {
throw new GradleException('Cannot directly or transitively depend on Guava.')
}
}
}
}
}
// Default dependencies for all subprojects
dependencies {
compile externalDependency.slf4jApi
@@ -16,7 +16,6 @@
package com.linkedin.d2.balancer.clients;
import com.google.common.annotations.VisibleForTesting;
import com.linkedin.common.callback.Callback;
import com.linkedin.common.util.None;
import com.linkedin.d2.balancer.util.URIRewriter;
@@ -90,7 +89,6 @@ public void shutdown(Callback<None> callback)
_transportClient.shutdown(callback);
}
@VisibleForTesting
public TransportClient getDecoratedClient()
{
return _transportClient;
@@ -17,7 +17,6 @@
package com.linkedin.d2.balancer.clients;
import com.google.common.annotations.VisibleForTesting;
import com.linkedin.common.callback.Callback;
import com.linkedin.common.util.None;
import com.linkedin.d2.balancer.LoadBalancerClient;
@@ -87,7 +86,6 @@ public TransportClient getWrappedClient()
return _client;
}
@VisibleForTesting
public TransportClient getDecoratedClient()
{
return _client;
@@ -16,7 +16,6 @@
package com.linkedin.d2.balancer.simple;
import com.google.common.annotations.VisibleForTesting;
import com.linkedin.common.callback.Callback;
import com.linkedin.common.callback.Callbacks;
import com.linkedin.common.callback.FutureCallback;
@@ -94,7 +93,6 @@
private final ScheduledExecutorService _executor;
private final Random _random = new Random();
@VisibleForTesting
public SimpleLoadBalancer(LoadBalancerState state, ScheduledExecutorService executorService)
{
this(state, new Stats(1000), new Stats(1000), 0, TimeUnit.SECONDS, executorService);
View
@@ -5,6 +5,7 @@
dependencies {
compile project(':data')
compile externalDependency.guava
compile externalDependency.jacksonCoreAsl_1_4
compile externalDependency.avro
testCompile externalDependency.testng
@@ -17,7 +17,6 @@
package com.linkedin.data.avro;
import com.google.common.collect.Maps;
import com.linkedin.data.Data;
import com.linkedin.data.DataMap;
import com.linkedin.data.schema.DataSchema;
@@ -384,7 +383,10 @@ protected void encodeFieldOptional(RecordDataSchema.Field field) throws IOExcept
@Override
protected void encodeFieldProperties(RecordDataSchema.Field field) throws IOException
{
_builder.writeProperties(Maps.filterKeys(field.getProperties(), property -> !RESERVED_DATA_PROPERTIES.contains(property)));
final Map<String, ?> filteredMap = field.getProperties().entrySet().stream()
.filter(entry -> !RESERVED_DATA_PROPERTIES.contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
_builder.writeProperties(filteredMap);
}
/**
@@ -16,7 +16,6 @@
package com.linkedin.data.avro;
import com.google.common.collect.ImmutableList;
import com.linkedin.data.DataMap;
import com.linkedin.data.TestUtil;
import com.linkedin.data.avro.util.AvroUtil;
@@ -31,6 +30,8 @@
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
@@ -1223,24 +1224,16 @@ public void testMissingDefaultFieldsOnDataMap() throws IOException
null
},
{
ImmutableList.of()
Collections.emptyList()
},
{
ImmutableList.of("foo", "bar", "baz")
Collections.unmodifiableList(Arrays.asList("foo", "bar", "baz"))
},
{
getList(() -> {
ArrayList<String> list = new ArrayList<>();
list.addAll(ImmutableList.of("foo", "bar"));
return list;
})
getList(() -> new ArrayList<>(Arrays.asList("foo", "bar")))
},
{
getList(() -> {
LinkedList<String> list = new LinkedList<>();
list.addAll(ImmutableList.of("foo", "bar"));
return list;
})
getList(() -> new LinkedList<>(Arrays.asList("foo", "bar")))
},
{
getList(() -> {
View
@@ -4,7 +4,6 @@ dependencies {
compile project(':entity-stream')
compile externalDependency.antlrRuntime
compile externalDependency.commonsLang3
compile externalDependency.guava
compile externalDependency.jacksonCore
testCompile project(':data-testutils')
@@ -16,20 +16,6 @@
package com.linkedin.data.schema.validator;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import com.linkedin.data.DataMap;
import com.linkedin.data.element.DataElement;
import com.linkedin.data.message.Message;
@@ -40,6 +26,17 @@
import com.linkedin.data.schema.NamedDataSchema;
import com.linkedin.data.schema.RecordDataSchema;
import com.linkedin.data.schema.TyperefDataSchema;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -197,8 +194,7 @@ public int compare(ValidatorInfo v1, ValidatorInfo v2)
}
};
private static final Cache<String, Class<? extends Validator>> VALIDATOR_CLASS_CACHE =
CacheBuilder.newBuilder().maximumSize(500).build();
private static final Map<String, Class<? extends Validator>> VALIDATOR_CLASS_CACHE = new ConcurrentHashMap<>();
// No-op {@link Validator} implementation to denote a negative cache value in {@link #VALIDATOR_CLASS_CACHE}
private static final Validator NULL_VALIDATOR = (context) -> {};
@@ -474,7 +470,7 @@ public void callback(List<String> path, DataSchema schema)
}
// If we have already seen this key before, use the cached Validator class
clazz = VALIDATOR_CLASS_CACHE.getIfPresent(key);
clazz = VALIDATOR_CLASS_CACHE.get(key);
if (clazz != null)
{
return (NULL_VALIDATOR.getClass().equals(clazz) ? null : clazz);
View
@@ -1,4 +1,4 @@
version=23.0.14
version=23.0.15
sonatypeUsername=please_set_in_home_dir_if_uploading_to_maven_central
sonatypePassword=please_set_in_home_dir_if_uploading_to_maven_central
org.gradle.configureondemand=true
@@ -7,5 +7,4 @@ dependencies {
testCompile externalDependency.mail
testCompile externalDependency.easymock
testCompile externalDependency.mockito
testCompile externalDependency.guava
}
@@ -23,15 +23,14 @@
import com.linkedin.r2.message.stream.StreamRequest;
import com.linkedin.r2.message.stream.entitystream.FullEntityReader;
import com.google.common.collect.ImmutableList;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -259,7 +258,8 @@ public void testMultipleDataSources() throws Exception
Collections.<String, String>emptyMap()).build();
final List<MultiPartMIMEDataSourceWriter> withPreambleDataSourceWriterList =
ImmutableList.of(purelyEmptyBodyWriterPreamble, headerLessBodyWriterPreamble, normalWriterPreamble);
Collections.unmodifiableList(Arrays.asList(purelyEmptyBodyWriterPreamble, headerLessBodyWriterPreamble,
normalWriterPreamble));
final MultiPartMIMEWriter.Builder multiPartMIMEWriterWithPreamble = new MultiPartMIMEWriter.Builder("preamble", "epilogue");
@@ -277,7 +277,8 @@ public void testMultipleDataSources() throws Exception
Collections.<String, String>emptyMap()).build();
final List<MultiPartMIMEDataSourceWriter> withoutPreambleDataSourceWriterList =
ImmutableList.of(purelyEmptyBodyWriterNoPreamble, headerLessBodyWriterNoPreamble, normalWriterNoPreamble);
Collections.unmodifiableList(Arrays.asList(purelyEmptyBodyWriterNoPreamble, headerLessBodyWriterNoPreamble,
normalWriterNoPreamble));
final MultiPartMIMEWriter.Builder multiPartMIMEWriterWithoutPreamble = new MultiPartMIMEWriter.Builder("", "epilogue");
@@ -42,13 +42,12 @@
import com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder;
import com.linkedin.r2.transport.http.client.HttpClientFactory;
import com.google.common.collect.ImmutableList;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -170,7 +169,7 @@ public void testEachSingleBodyDataSource(final int chunkSize, final MIMEDataPart
final MultiPartMIMEWriter writer = new MultiPartMIMEWriter.Builder("some preamble", "").appendDataSource(inputStreamDataSource).build();
executeRequestAndAssert(writer, ImmutableList.of(bodyPart));
executeRequestAndAssert(writer, Collections.unmodifiableList(Collections.singletonList(bodyPart)));
}
@Test(dataProvider = "eachSingleBodyDataSource", enabled = false)
@@ -188,7 +187,7 @@ public void testEachSingleBodyDataSourceMultipleTimes(final int chunkSize, final
final MultiPartMIMEWriter writer = new MultiPartMIMEWriter.Builder("some preamble", "").appendDataSources(dataSources).build();
executeRequestAndAssert(writer, ImmutableList.of(bodyPart, bodyPart, bodyPart, bodyPart));
executeRequestAndAssert(writer, Collections.unmodifiableList(Arrays.asList(bodyPart, bodyPart, bodyPart, bodyPart)));
}
///////////////////////////////////////////////////////////////////////////////////////
@@ -227,7 +226,8 @@ public void testMultipleBodies(final int chunkSize) throws Exception
.appendDataSource(headerLessBodyInputStream).appendDataSource(bodyLessBodyInputStream)
.appendDataSource(purelyEmptyBodyInputStream).build();
executeRequestAndAssert(writer, ImmutableList.of(_normalBody, _headerLessBody, _bodyLessBody, _purelyEmptyBody));
executeRequestAndAssert(writer, Collections.unmodifiableList(Arrays.asList(_normalBody, _headerLessBody,
_bodyLessBody, _purelyEmptyBody)));
}
@Test
@@ -24,8 +24,6 @@
import com.linkedin.multipart.MultiPartMIMEReaderCallback;
import com.linkedin.multipart.SinglePartMIMEReaderCallback;
import com.google.common.collect.ImmutableMap;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -156,38 +154,38 @@ public static ByteString trimTrailingCRLF(final ByteString javaxMailPayload)
{
//Non javax mail sources:
final byte[] bodyAbytes = "BODY_A".getBytes();
final Map<String, String> bodyAHeaders = ImmutableMap.of("headerA", "valueA");
final Map<String, String> bodyAHeaders = Collections.unmodifiableMap(Collections.singletonMap("headerA", "valueA"));
BODY_A = new MIMEDataPart(ByteString.copy(bodyAbytes), bodyAHeaders);
final byte[] bodyBbytes = "BODY_B".getBytes();
final Map<String, String> bodyBHeaders = ImmutableMap.of("headerB", "valueB");
final Map<String, String> bodyBHeaders = Collections.unmodifiableMap(Collections.singletonMap("headerB", "valueB"));
BODY_B = new MIMEDataPart(ByteString.copy(bodyBbytes), bodyBHeaders);
//body c has no headers
final byte[] bodyCbytes = "BODY_C".getBytes();
BODY_C = new MIMEDataPart(ByteString.copy(bodyCbytes), Collections.<String, String>emptyMap());
final byte[] bodyDbytes = "BODY_D".getBytes();
final Map<String, String> bodyDHeaders = ImmutableMap.of("headerD", "valueD");
final Map<String, String> bodyDHeaders = Collections.unmodifiableMap(Collections.singletonMap("headerD", "valueD"));
BODY_D = new MIMEDataPart(ByteString.copy(bodyDbytes), bodyDHeaders);
final byte[] body1bytes = "BODY_1".getBytes();
final Map<String, String> body1Headers = ImmutableMap.of("header1", "value1");
final Map<String, String> body1Headers = Collections.unmodifiableMap(Collections.singletonMap("header1", "value1"));
BODY_1 = new MIMEDataPart(ByteString.copy(body1bytes), body1Headers);
final byte[] body2bytes = "BODY_2".getBytes();
final Map<String, String> body2Headers = ImmutableMap.of("header2", "value2");
final Map<String, String> body2Headers = Collections.unmodifiableMap(Collections.singletonMap("header2", "value2"));
BODY_2 = new MIMEDataPart(ByteString.copy(body2bytes), body2Headers);
//body 3 is completely empty
BODY_3 = new MIMEDataPart(ByteString.empty(), Collections.<String, String>emptyMap());
final byte[] body4bytes = "BODY_4".getBytes();
final Map<String, String> body4Headers = ImmutableMap.of("header4", "value4");
final Map<String, String> body4Headers = Collections.unmodifiableMap(Collections.singletonMap("header4", "value4"));
BODY_4 = new MIMEDataPart(ByteString.copy(body4bytes), body4Headers);
final byte[] localInputStreamBytes = "local input stream".getBytes();
final Map<String, String> localInputStreamHeaders = ImmutableMap.of("local1", "local2");
final Map<String, String> localInputStreamHeaders = Collections.unmodifiableMap(Collections.singletonMap("local1", "local2"));
BODY_5 = new MIMEDataPart(ByteString.copy(localInputStreamBytes), localInputStreamHeaders);
}
Oops, something went wrong.

0 comments on commit 5404831

Please sign in to comment.