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 #228

Merged
merged 2 commits into from
Jan 6, 2020
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
22 changes: 11 additions & 11 deletions .baseline/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<property name="optional" value="true"/>
</module>
<module name="SuppressWarningsFilter"/> <!-- baseline-gradle: README.md -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<module name="TreeWalker">
<module name="SuppressionCommentFilter"/> <!-- baseline-gradle: README.md -->
<module name="SuppressionCommentFilter">
Expand Down Expand Up @@ -84,11 +87,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 All @@ -110,7 +115,6 @@
<module name="EmptyStatement"/> <!-- Java Style Guide: One statement per line -->
<module name="EqualsHashCode"/>
<module name="FallThrough"/> <!-- Java Style Guide: Fall-through: commented -->
<module name="FinalClass"/> <!-- Java Coding Guidelines: Private constructors -->
<module name="GenericWhitespace"> <!-- Java Style Guide: Horizontal whitespace -->
<message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
Expand Down Expand Up @@ -369,10 +373,6 @@
<property name="format" value="\bIOUtils\.toString\("/>
<property name="message" value="Prefer Guava''s [CharStreams,Files,Resources].toString to avoid charset/stream closing issues."/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="static enum"/>
<property name="message" value="Redundant ''static'' modifier."/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="\/\/TODO|\/\/ TODO(?!\([^()\s]+\): )"/>
<property name="message" value="TODO format: // TODO(#issue): explanation"/>
Expand Down Expand Up @@ -422,6 +422,7 @@
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<property name="allowEmptyLambdas" value="true"/>
<property name="ignoreEnhancedForColon" value="false"/>
<message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
Expand All @@ -435,7 +436,7 @@
</module>
<module name="CyclomaticComplexity"/> <!-- Java Coding Guidelines: Reduce Cyclomatic Complexity -->
<module name="DesignForExtension"> <!-- Java Coding Guidelines: Design for extension -->
<property name="ignoredAnnotations" value="Test, Before, BeforeEach, After, AfterEach, BeforeClass, BeforeAll, AfterClass, AfterAll"/>
<property name="ignoredAnnotations" value="ParameterizedTest, Test, Before, BeforeEach, After, AfterEach, BeforeClass, BeforeAll, AfterClass, AfterAll"/>
</module>
<module name="JavadocMethod"> <!-- Java Style Guide: Where Javadoc is used -->
<property name="scope" value="public"/>
Expand Down Expand Up @@ -468,10 +469,9 @@
<module name="NestedTryDepth"/> <!-- Java Coding Guide: Try/catch blocks: never nested -->
<module name="NonEmptyAtclauseDescription"/> <!-- Java Style Guide: At-clauses -->
<module name="ParameterName"> <!-- Java Style Guide: Parameter names -->
<property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
<property name="format" value="^_?[a-z][a-zA-Z0-9]+$"/>
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc"/> <!-- Java Style Guide: General form -->
<module name="SummaryJavadocCheck"> <!-- Java Coding Guidelines: Javadoc -->
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ buildscript {
classpath 'com.netflix.nebula:gradle-info-plugin:5.2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:nebula-publishing-plugin:14.1.1'
classpath 'com.palantir.baseline:gradle-baseline-java:0.59.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.45.1'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.2'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.1.0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private static Buffer zip(String content) throws IOException {
return gzipBytes;
}

private static class FakeEndpoint implements Endpoint {
private static final class FakeEndpoint implements Endpoint {
private BiConsumer<Map<String, String>, UrlBuilder> renderPath;
private HttpMethod method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Optional<ListenableFuture<Response>> maybeExecute(Endpoint endpoint, Requ
}
}

private class BlacklistingCallback implements FutureCallback<Response> {
private final class BlacklistingCallback implements FutureCallback<Response> {
@Override
public void onSuccess(Response response) {
// TODO(jellis): use the Retry-After header (if present) to determine how long to blacklist the channel
Expand All @@ -74,7 +74,7 @@ public void onSuccess(Response response) {
}

@Override
public void onFailure(Throwable throwable) {
public void onFailure(Throwable _throwable) {
isBlacklisted.put(KEY, VALUE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void onSuccess(Response result) {
}

@Override
public void onFailure(Throwable throwable) {
public void onFailure(Throwable _throwable) {
listener.onIgnore();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public ListenableFuture<Response> execute(Endpoint endpoint, Request request) {
ListenableFuture<Response> response = delegate.execute(endpoint, request);
Futures.addCallback(response, new FutureCallback<>() {
@Override
public void onSuccess(@Nullable Response result) {
public void onSuccess(@Nullable Response _result) {
record(endpoint);
}

@Override
public void onFailure(Throwable throwable) {
public void onFailure(Throwable _throwable) {
record(endpoint);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private AlwaysThrowingChannel(String serviceName) {
}

@Override
public ListenableFuture<Response> execute(Endpoint endpoint, Request request) {
public ListenableFuture<Response> execute(Endpoint _endpoint, Request _request) {
return Futures.immediateFailedFuture(
new SafeIllegalStateException("Service not configured", SafeArg.of("serviceName", serviceName)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class ChannelsTest {
@Mock private Channel delegate;
private Endpoint endpoint = new Endpoint() {
@Override
public void renderPath(Map<String, String> params, UrlBuilder url) {}
public void renderPath(Map<String, String> _params, UrlBuilder _url) {}

@Override
public HttpMethod httpMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import com.google.common.util.concurrent.SettableFuture;
Expand Down Expand Up @@ -86,7 +86,7 @@ public void testUnavailable() {
mockLimitUnavailable();

assertThat(channel.maybeExecute(endpoint, request)).isEmpty();
verifyZeroInteractions(listener);
verifyNoMoreInteractions(listener);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Map<String, List<String>> headers() {

private static final class TestEndpoint implements Endpoint {
@Override
public void renderPath(Map<String, String> params, UrlBuilder url) {}
public void renderPath(Map<String, String> _params, UrlBuilder _url) {}

@Override
public HttpMethod httpMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class UserAgentChannelTest {
private static final UserAgent baseAgent = UserAgent.of(UserAgent.Agent.of("test-class", "1.2.3"));
private static final Endpoint endpoint = new Endpoint() {
@Override
public void renderPath(Map<String, String> params, UrlBuilder url) {}
public void renderPath(Map<String, String> _params, UrlBuilder _url) {}

@Override
public HttpMethod httpMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.exceptions.SafeRuntimeException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -117,7 +118,7 @@ private static HttpRequest.Builder newRequestBuilder(UrlBuilder url) {
try {
return HttpRequest.newBuilder().uri(url.build().toURI());
} catch (URISyntaxException e) {
throw new RuntimeException("Failed to construct URI, this is a bug", e);
throw new SafeRuntimeException("Failed to construct URI, this is a bug", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public ListenableFuture<Response> execute(Endpoint endpoint, Request request) {
SettableFuture<Response> future = SettableFuture.create();
okCall.enqueue(new Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException exception) {
public void onFailure(okhttp3.Call _call, IOException exception) {
future.setException(exception);
}

@Override
public void onResponse(okhttp3.Call call, okhttp3.Response response) {
public void onResponse(okhttp3.Call _call, okhttp3.Response response) {
future.set(OkHttpResponse.wrap(response));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public Deserializer<Void> emptyBodyDeserializer() {
return response -> {
try {
if (response.body().read() != -1) {
throw new RuntimeException("Expected empty response body");
throw new SafeRuntimeException("Expected empty response body");
}
} catch (IOException e) {
throw new RuntimeException("Failed to read from response body", e);
throw new SafeRuntimeException("Failed to read from response body", e);
}
return null;
};
Expand Down Expand Up @@ -142,7 +142,7 @@ public RequestBody serialize(T value) {
bytes.flush();
bytes.close();
} catch (IOException e) {
throw new RuntimeException("Failed to close or flush ByteStream. This is a bug.", e);
throw new SafeRuntimeException("Failed to close or flush ByteStream. This is a bug.", e);
}

return new RequestBody() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public <T> Serializer<T> serializer(TypeMarker<T> type) {
try {
writer.writeValue(output, value);
} catch (IOException e) {
throw new RuntimeException("Failed to serialize payload, this is a bug", e);
throw new SafeRuntimeException("Failed to serialize payload, this is a bug", e);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static final class StubEncoding implements Encoding {
}

@Override
public <T> Serializer<T> serializer(TypeMarker<T> type) {
public <T> Serializer<T> serializer(TypeMarker<T> _type) {
return (value, output) -> {
// nop
};
Expand Down Expand Up @@ -173,7 +173,7 @@ public String toString() {
}
}

private static class TestResponse implements Response {
private static final class TestResponse implements Response {

private InputStream body = new ByteArrayInputStream(new byte[] {});
private int code = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private RemoteExceptions() {}
* Similar to {@link com.google.common.util.concurrent.Futures#getUnchecked(Future)}, except it propagates
* {@link RemoteException}s directly, rather than wrapping them in an {@link UncheckedExecutionException}.
*/
@SuppressWarnings("ThrowError") // match behavior of Futures.getUnchecked(Future)
public static <T> T getUnchecked(Future<T> future) {
try {
return future.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.UnsafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import java.io.ByteArrayOutputStream;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -131,7 +132,7 @@ public URL build() {

return new URL(protocol, host, port, file.toString());
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Malformed URL", e);
throw new SafeIllegalArgumentException("Malformed URL", e);
}
}

Expand Down