Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excavator: Upgrades Baseline to the latest version #1272

Merged
merged 3 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@
<module name="AvoidStarImport"/> <!-- Java Style Guide: No wildcard imports -->
<module name="AvoidStaticImport"> <!-- Java Style Guide: No static imports -->
<property name="excludes" value="
com.google.common.base.Preconditions.*,
com.palantir.logsafe.Preconditions.*,
java.util.Collections.*,
java.util.stream.Collectors.*,
com.palantir.logsafe.Preconditions.*,
com.google.common.base.Preconditions.*,
org.apache.commons.lang3.Validate.*"/>
org.apache.commons.lang3.Validate.*,
org.assertj.core.api.Assertions.*,
org.mockito.Mockito.*"/>
</module>
<module name="ClassTypeParameterName"> <!-- Java Style Guide: Type variable names -->
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
Expand Down
1 change: 1 addition & 0 deletions .baseline/spotless/eclipse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:gradle-dependency-lock-plugin:7.0.1'
classpath 'com.netflix.nebula:nebula-publishing-plugin:14.0.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.7.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.25.0'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.2'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.1.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:1.12.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Socket wrap(Socket socket) throws SocketException {
return socket;
}

@Override
public String toString() {
return "KeepAliveSslSocketFactory{delegate=" + delegate + '}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void meshProxy_maxRetriesMustBe0() throws Exception {

ClientConfiguration validConfig = ClientConfigurations.of(meshProxyServiceConfig(uris, 0));
assertThat(validConfig.meshProxy()).isEqualTo(Optional.of(HostAndPort.fromParts("localhost", 1234)));
assertThat(validConfig.maxNumRetries()).isEqualTo(0);
assertThat(validConfig.maxNumRetries()).isZero();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void deserializeJdk8ModulePresentOptional() throws IOException {

@Test
public void deserializeJdk8ModuleAbsentOptional() throws IOException {
assertThat(MAPPER.readValue("null", Optional.class)).isEqualTo(Optional.empty());
assertThat(MAPPER.readValue("null", Optional.class)).isNotPresent();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum NeverRetryingBackoffStrategy implements BackoffStrategy {
INSTANCE;

@Override
public boolean backoff(int numFailedAttempts) {
public boolean backoff(int _numFailedAttempts) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public PathTemplateHeaderEnrichmentContract(Contract delegate) {
}

@Override
protected void processMetadata(Class<?> targetType, Method method, MethodMetadata metadata) {
protected void processMetadata(Class<?> _targetType, Method _method, MethodMetadata metadata) {
metadata.template()
.header(OkhttpTraceInterceptor.PATH_TEMPLATE_HEADER,
metadata.template().method() + " "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum PathTemplateHeaderRewriter implements RequestInterceptor {
INSTANCE;

@Override
public void apply(RequestTemplate template) {
public void apply(RequestTemplate _template) {
// nop
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SlashEncodingContract(Contract delegate) {
}

@Override
protected void processMetadata(Class<?> targetType, Method method, MethodMetadata metadata) {
protected void processMetadata(Class<?> _targetType, Method _method, MethodMetadata metadata) {
metadata.template().decodeSlash(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public void testConfigRefresh() throws Exception {
server1.enqueue(new MockResponse().setBody("\"server1\""));
assertThat(proxy.string()).isEqualTo("server1");
assertThat(server1.getRequestCount()).isEqualTo(1);
assertThat(server2.getRequestCount()).isEqualTo(0);
assertThat(server2.getRequestCount()).isZero();

// Call 2
server1.enqueue(new MockResponse().setBody("\"server1\""));
assertThat(proxy.string()).isEqualTo("server1");
assertThat(server1.getRequestCount()).isEqualTo(2);
assertThat(server2.getRequestCount()).isEqualTo(0);
assertThat(server2.getRequestCount()).isZero();

// Switch config
refreshableConfig.set(config2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public void testAuthenticatedProxy() throws Exception {
private static ProxySelector createProxySelector(String host, int port) {
return new ProxySelector() {
@Override
public List<Proxy> select(URI uri) {
public List<Proxy> select(URI _uri) {
InetSocketAddress addr = new InetSocketAddress(host, port);
return ImmutableList.of(new Proxy(Proxy.Type.HTTP, addr));
}

@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {}
public void connectFailed(URI _uri, SocketAddress _sa, IOException _ioe) {}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ private void runTwoRequestsInParallel() {
ExecutorService executor = Executors.newFixedThreadPool(2);
CompletableFuture<?> first = CompletableFuture.runAsync(() -> {
Tracer.initTrace(Optional.of(true), "first");
OpenSpan ignored = Tracer.startSpan("");
Tracer.fastStartSpan("");
service.string();
}, executor);
CompletableFuture<?> second = CompletableFuture.runAsync(() -> {
Tracer.initTrace(Optional.of(true), "second");
OpenSpan ignored = Tracer.startSpan("");
Tracer.fastStartSpan("");
service.string();
}, executor);
first.join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testOptional() {
@Test
public void testNonOptional() {
assertThat(service.getNonOptional("something")).isEqualTo(ImmutableMap.of("something", "something"));
assertThat(service.getNonOptional(null)).isEqualTo(ImmutableMap.<String, String>of());
assertThat(service.getNonOptional(null)).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

public class GuavaTestServer extends Application<Configuration> {
@Override
public final void run(Configuration config, final Environment env) throws Exception {
public final void run(Configuration _config, final Environment env) throws Exception {
env.jersey().register(ConjureJerseyFeature.INSTANCE);
env.jersey().register(new JacksonMessageBodyProvider(ObjectMappers.newServerObjectMapper()));
env.jersey().register(new TestResource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testOptional() {
@Test
public void testNonOptional() {
assertThat(service.getNonOptional("something")).isEqualTo(ImmutableMap.of("something", "something"));
assertThat(service.getNonOptional(null)).isEqualTo(ImmutableMap.<String, String>of());
assertThat(service.getNonOptional(null)).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

public class Java8TestServer extends Application<Configuration> {
@Override
public final void run(Configuration config, final Environment env) throws Exception {
public final void run(Configuration _config, final Environment env) throws Exception {
env.jersey().register(ConjureJerseyFeature.INSTANCE);
env.jersey().register(new JacksonMessageBodyProvider(ObjectMappers.newServerObjectMapper()));
env.jersey().register(new EmptyOptionalTo204ExceptionMapper());
Expand All @@ -61,7 +61,7 @@ public final void run(Configuration config, final Environment env) throws Except
@Provider
private static final class EmptyOptionalTo204ExceptionMapper implements ExceptionMapper<EmptyOptionalException> {
@Override
public Response toResponse(EmptyOptionalException exception) {
public Response toResponse(EmptyOptionalException _exception) {
return Response.noContent().build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void initialize(Bootstrap<ServiceConfigTestAppConfig> bootstrap) {
}

@Override
public void run(ServiceConfigTestAppConfig configuration, Environment environment) throws Exception {
public void run(ServiceConfigTestAppConfig _configuration, Environment environment) throws Exception {
environment.jersey().register(new Resource());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public interface Service {

public static class Server extends Application<Configuration> {
@Override
public final void run(Configuration config, final Environment env) throws Exception {
public final void run(Configuration _config, final Environment env) throws Exception {
env.jersey().register(resource);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testUsesStringDecoderWithTextPlain() throws Exception {
Object decodedObject = textDelegateDecoder.decode(response, String.class);

assertThat("text response").isEqualTo(decodedObject);
verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
}

@Test
Expand All @@ -100,7 +100,7 @@ public void testUsesStringDecoderWithTextPlainAndCharset() throws Exception {
Object decodedObject = textDelegateDecoder.decode(response, String.class);

assertThat("text response").isEqualTo(decodedObject);
verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
}

@Test
Expand All @@ -110,7 +110,7 @@ public void testUsesStringDecoderWithTextPlainWithWeirdHeaderCapitalization() th
Object decodedObject = textDelegateDecoder.decode(response, String.class);

assertThat("text response").isEqualTo(decodedObject);
verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
}

@Test
Expand All @@ -120,7 +120,7 @@ public void testReturnsEmptyStringForNullResponseBodyWithTextPlain() throws Exce
Object decodedObject = textDelegateDecoder.decode(response, String.class);

assertThat(decodedObject).isEqualTo("");
verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;

import com.google.common.collect.Maps;
import com.google.common.net.HttpHeaders;
Expand Down Expand Up @@ -66,14 +66,14 @@ public void doesNotUseDelegateWhenContentTypeIsTextPlain() {
headers.put(HttpHeaders.CONTENT_TYPE, Arrays.asList(MediaType.TEXT_PLAIN));
requestTemplate.headers(headers);
textDelegateEncoder.encode(null, null, requestTemplate);
verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
}

@Test
public void doesNotUseDelegateWhenContentTypeHeaderHasArbitraryCase() {
headers.put("Content-TYPE", Arrays.asList(MediaType.TEXT_PLAIN));
requestTemplate.headers(headers);
textDelegateEncoder.encode(null, null, requestTemplate);
verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public void testServiceException() throws IOException {

Map<String, Object> rawError =
ObjectMappers.newClientObjectMapper().readValue(body, new TypeReference<Map<String, Object>>() {});
assertThat(rawError.get("errorCode")).isEqualTo(ErrorType.INVALID_ARGUMENT.code().toString());
assertThat(rawError.get("errorName")).isEqualTo(ErrorType.INVALID_ARGUMENT.name());
assertThat(rawError.get("parameters")).isEqualTo(ImmutableMap.of("arg", "value"));
assertThat(rawError).containsEntry("errorCode", ErrorType.INVALID_ARGUMENT.code().toString());
assertThat(rawError).containsEntry("errorName", ErrorType.INVALID_ARGUMENT.name());
assertThat(rawError).containsEntry("parameters", ImmutableMap.of("arg", "value"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class AsyncSerializableErrorCallAdapterFactory extends CallAdapter.Factory
private AsyncSerializableErrorCallAdapterFactory() {}

@Override
public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
public CallAdapter<?, ?> get(Type returnType, Annotation[] _annotations, Retrofit _retrofit) {
Type outerType = getRawType(returnType);
if (outerType != CompletableFuture.class && outerType != ListenableFuture.class) {
return null;
Expand Down Expand Up @@ -91,15 +91,15 @@ public boolean cancel(boolean mayInterruptIfRunning) {
}

@Override
public void onResponse(Call<R> call, Response<R> response) {
public void onResponse(Call<R> _call, Response<R> response) {
boolean futureWasCancelled = !set(response.body());
if (futureWasCancelled) {
close(response);
}
}

@Override
public void onFailure(Call<R> call, Throwable throwable) {
public void onFailure(Call<R> _call, Throwable throwable) {
// TODO(rfink): Would be good to not leak okhttp internals here
if (throwable instanceof IoRemoteException) {
setException(((IoRemoteException) throwable).getWrappedException());
Expand Down Expand Up @@ -157,15 +157,15 @@ public boolean cancel(boolean mayInterruptIfRunning) {

call.enqueue(new Callback<R>() {
@Override
public void onResponse(Call<R> call, Response<R> response) {
public void onResponse(Call<R> _call, Response<R> response) {
boolean futureWasCancelled = !future.complete(response.body());
if (futureWasCancelled) {
close(response);
}
}

@Override
public void onFailure(Call<R> call, Throwable throwable) {
public void onFailure(Call<R> _call, Throwable throwable) {
// TODO(rfink): Would be good to not leak okhttp internals here
if (throwable instanceof IoRemoteException) {
future.completeExceptionally(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class OptionalObjectToStringConverterFactory extends Converter.Fact
private OptionalObjectToStringConverterFactory() {}

@Override
public Converter<?, String> stringConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
public Converter<?, String> stringConverter(Type type, Annotation[] annotations, Retrofit _retrofit) {
Optional<?> pathQueryAnnotation = ImmutableList.copyOf(annotations)
.stream()
.map(Annotation::annotationType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ public void async_retrofit_call_should_throw_RemoteException_for_server_serializ
retrofit2.Call<String> call = service.getRelative();
call.enqueue(new retrofit2.Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
public void onResponse(Call<String> _call, Response<String> _response) {
failBecauseExceptionWasNotThrown(RemoteException.class);
}

@Override
public void onFailure(Call<String> call, Throwable throwable) {
public void onFailure(Call<String> _call, Throwable throwable) {
assertThat(throwable).isInstanceOf(RemoteException.class);
assertThat(((RemoteException) throwable).getError()).isEqualTo(ERROR);
assertionsPassed.countDown(); // if you delete this countdown latch then this test will vacuously pass.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public void testConfigRefresh() throws Exception {
server1.enqueue(new MockResponse().setBody("\"server1\""));
assertThat(proxy.get().execute().body()).isEqualTo("server1");
assertThat(server1.getRequestCount()).isEqualTo(1);
assertThat(server2.getRequestCount()).isEqualTo(0);
assertThat(server2.getRequestCount()).isZero();

// Call 2
server1.enqueue(new MockResponse().setBody("\"server1\""));
assertThat(proxy.get().execute().body()).isEqualTo("server1");
assertThat(server1.getRequestCount()).isEqualTo(2);
assertThat(server2.getRequestCount()).isEqualTo(0);
assertThat(server2.getRequestCount()).isZero();

// Switch config
refreshableConfig.set(config2);
Expand Down
Loading