Enable checkstyle overload method ordering rule for Google Java Style (#1656)

This commit is contained in:
Trask Stalnaker 2020-11-17 14:41:14 -08:00 committed by GitHub
parent cea28356c6
commit 2e51003900
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 67 deletions

View File

@ -270,9 +270,7 @@
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF,
RECORD_COMPONENT_DEF"/> RECORD_COMPONENT_DEF"/>
</module> </module>
<!--
<module name="OverloadMethodsDeclarationOrder"/> <module name="OverloadMethodsDeclarationOrder"/>
-->
<!-- there are only a few violations of this, and they all appear to be for good reasons <!-- there are only a few violations of this, and they all appear to be for good reasons
<module name="VariableDeclarationUsageDistance"/> <module name="VariableDeclarationUsageDistance"/>
--> -->

View File

@ -64,7 +64,7 @@ public abstract class HttpClientTracer<REQUEST, CARRIER, RESPONSE> extends BaseT
} }
public Span startSpan(REQUEST request, long startTimeNanos) { public Span startSpan(REQUEST request, long startTimeNanos) {
return startSpan(request, spanNameForRequest(request), startTimeNanos); return internalStartSpan(request, spanNameForRequest(request), startTimeNanos);
} }
public Scope startScope(Span span, CARRIER carrier) { public Scope startScope(Span span, CARRIER carrier) {
@ -103,7 +103,7 @@ public abstract class HttpClientTracer<REQUEST, CARRIER, RESPONSE> extends BaseT
* Returns a new client {@link Span} if there is no client {@link Span} in the current {@link * Returns a new client {@link Span} if there is no client {@link Span} in the current {@link
* Context}, or an invalid {@link Span} otherwise. * Context}, or an invalid {@link Span} otherwise.
*/ */
private Span startSpan(REQUEST request, String name, long startTimeNanos) { private Span internalStartSpan(REQUEST request, String name, long startTimeNanos) {
Context context = Context.current(); Context context = Context.current();
Span clientSpan = context.get(CONTEXT_CLIENT_SPAN_KEY); Span clientSpan = context.get(CONTEXT_CLIENT_SPAN_KEY);

View File

@ -88,6 +88,11 @@ public abstract class TracingRequestStreamHandler implements RequestStreamHandle
delegate.write(b, off, len); delegate.write(b, off, len);
} }
@Override
public void write(int b) throws IOException {
delegate.write(b);
}
@Override @Override
public void flush() throws IOException { public void flush() throws IOException {
delegate.flush(); delegate.flush();
@ -99,10 +104,5 @@ public abstract class TracingRequestStreamHandler implements RequestStreamHandle
tracer.end(span); tracer.end(span);
OpenTelemetrySdk.getGlobalTracerManagement().forceFlush().join(1, TimeUnit.SECONDS); OpenTelemetrySdk.getGlobalTracerManagement().forceFlush().join(1, TimeUnit.SECONDS);
} }
@Override
public void write(int b) throws IOException {
delegate.write(b);
}
} }
} }

View File

@ -135,13 +135,6 @@ public class TracingCqlSession implements CqlSession {
return session.getMetrics(); return session.getMetrics();
} }
@Override
@Nullable
public <RequestT extends Request, ResultT> ResultT execute(
@NonNull RequestT request, @NonNull GenericType<ResultT> resultType) {
return session.execute(request, resultType);
}
@Override @Override
@NonNull @NonNull
public CompletionStage<Void> closeFuture() { public CompletionStage<Void> closeFuture() {
@ -170,15 +163,21 @@ public class TracingCqlSession implements CqlSession {
session.close(); session.close();
} }
@Override
@Nullable
public <RequestT extends Request, ResultT> ResultT execute(
@NonNull RequestT request, @NonNull GenericType<ResultT> resultType) {
return session.execute(request, resultType);
}
@Override @Override
@NonNull @NonNull
public ResultSet execute(@NonNull Statement<?> statement) { public ResultSet execute(@NonNull String query) {
String query = getQuery(statement);
Span span = tracer().startSpan(session, query); Span span = tracer().startSpan(session, query);
try (Scope ignored = tracer().startScope(span)) { try (Scope ignored = tracer().startScope(span)) {
try { try {
ResultSet resultSet = session.execute(statement); ResultSet resultSet = session.execute(query);
tracer().onResponse(span, resultSet.getExecutionInfo()); tracer().onResponse(span, resultSet.getExecutionInfo());
return resultSet; return resultSet;
} catch (RuntimeException e) { } catch (RuntimeException e) {
@ -192,12 +191,13 @@ public class TracingCqlSession implements CqlSession {
@Override @Override
@NonNull @NonNull
public ResultSet execute(@NonNull String query) { public ResultSet execute(@NonNull Statement<?> statement) {
String query = getQuery(statement);
Span span = tracer().startSpan(session, query); Span span = tracer().startSpan(session, query);
try (Scope ignored = tracer().startScope(span)) { try (Scope ignored = tracer().startScope(span)) {
try { try {
ResultSet resultSet = session.execute(query); ResultSet resultSet = session.execute(statement);
tracer().onResponse(span, resultSet.getExecutionInfo()); tracer().onResponse(span, resultSet.getExecutionInfo());
return resultSet; return resultSet;
} catch (RuntimeException e) { } catch (RuntimeException e) {

View File

@ -48,11 +48,21 @@ public class TracingList extends TracingIterable implements List<ConsumerRecord<
return delegate.add(consumerRecord); return delegate.add(consumerRecord);
} }
@Override
public void add(int index, ConsumerRecord element) {
delegate.add(index, element);
}
@Override @Override
public boolean remove(Object o) { public boolean remove(Object o) {
return delegate.remove(o); return delegate.remove(o);
} }
@Override
public ConsumerRecord<?, ?> remove(int index) {
return delegate.remove(index);
}
@Override @Override
public boolean containsAll(Collection<?> c) { public boolean containsAll(Collection<?> c) {
return delegate.containsAll(c); return delegate.containsAll(c);
@ -94,16 +104,6 @@ public class TracingList extends TracingIterable implements List<ConsumerRecord<
return delegate.set(index, element); return delegate.set(index, element);
} }
@Override
public void add(int index, ConsumerRecord element) {
delegate.add(index, element);
}
@Override
public ConsumerRecord<?, ?> remove(int index) {
return delegate.remove(index);
}
@Override @Override
public int indexOf(Object o) { public int indexOf(Object o) {
return delegate.indexOf(o); return delegate.indexOf(o);

View File

@ -44,17 +44,6 @@ public class Bridging {
} }
} }
public static io.opentelemetry.api.trace.Span toAgentOrNull(Span applicationSpan) {
if (!applicationSpan.getSpanContext().isValid()) {
// no need to wrap
return io.opentelemetry.api.trace.Span.getInvalid();
} else if (applicationSpan instanceof ApplicationSpan) {
return ((ApplicationSpan) applicationSpan).getAgentSpan();
} else {
return null;
}
}
public static SpanContext toApplication(io.opentelemetry.api.trace.SpanContext agentContext) { public static SpanContext toApplication(io.opentelemetry.api.trace.SpanContext agentContext) {
if (agentContext.isRemote()) { if (agentContext.isRemote()) {
return SpanContext.createFromRemoteParent( return SpanContext.createFromRemoteParent(
@ -71,6 +60,32 @@ public class Bridging {
} }
} }
private static TraceState toApplication(io.opentelemetry.api.trace.TraceState agentTraceState) {
TraceState.Builder applicationTraceState = TraceState.builder();
agentTraceState.forEach(applicationTraceState::set);
return applicationTraceState.build();
}
public static io.opentelemetry.api.trace.Span toAgentOrNull(Span applicationSpan) {
if (!applicationSpan.getSpanContext().isValid()) {
// no need to wrap
return io.opentelemetry.api.trace.Span.getInvalid();
} else if (applicationSpan instanceof ApplicationSpan) {
return ((ApplicationSpan) applicationSpan).getAgentSpan();
} else {
return null;
}
}
public static io.opentelemetry.api.trace.Span.Kind toAgentOrNull(Span.Kind applicationSpanKind) {
try {
return io.opentelemetry.api.trace.Span.Kind.valueOf(applicationSpanKind.name());
} catch (IllegalArgumentException e) {
log.debug("unexpected span kind: {}", applicationSpanKind.name());
return null;
}
}
public static io.opentelemetry.api.trace.SpanContext toAgent(SpanContext applicationContext) { public static io.opentelemetry.api.trace.SpanContext toAgent(SpanContext applicationContext) {
if (applicationContext.isRemote()) { if (applicationContext.isRemote()) {
return io.opentelemetry.api.trace.SpanContext.createFromRemoteParent( return io.opentelemetry.api.trace.SpanContext.createFromRemoteParent(
@ -150,21 +165,6 @@ public class Bridging {
return agentCanonicalCode; return agentCanonicalCode;
} }
public static io.opentelemetry.api.trace.Span.Kind toAgentOrNull(Span.Kind applicationSpanKind) {
try {
return io.opentelemetry.api.trace.Span.Kind.valueOf(applicationSpanKind.name());
} catch (IllegalArgumentException e) {
log.debug("unexpected span kind: {}", applicationSpanKind.name());
return null;
}
}
private static TraceState toApplication(io.opentelemetry.api.trace.TraceState agentTraceState) {
TraceState.Builder applicationTraceState = TraceState.builder();
agentTraceState.forEach(applicationTraceState::set);
return applicationTraceState.build();
}
private static io.opentelemetry.api.trace.TraceState toAgent(TraceState applicationTraceState) { private static io.opentelemetry.api.trace.TraceState toAgent(TraceState applicationTraceState) {
io.opentelemetry.api.trace.TraceState.Builder agentTraceState = io.opentelemetry.api.trace.TraceState.Builder agentTraceState =
io.opentelemetry.api.trace.TraceState.builder(); io.opentelemetry.api.trace.TraceState.builder();

View File

@ -68,14 +68,6 @@ public class AdviceUtils {
} }
} }
private static void finishSpanIfPresentInAttributes(
Map<String, Object> attributes, Throwable throwable) {
io.opentelemetry.context.Context context =
(io.opentelemetry.context.Context) attributes.remove(CONTEXT_ATTRIBUTE);
finishSpanIfPresent(context, throwable);
}
static void finishSpanIfPresent(io.opentelemetry.context.Context context, Throwable throwable) { static void finishSpanIfPresent(io.opentelemetry.context.Context context, Throwable throwable) {
if (context != null) { if (context != null) {
Span span = Span.fromContext(context); Span span = Span.fromContext(context);
@ -87,6 +79,14 @@ public class AdviceUtils {
} }
} }
private static void finishSpanIfPresentInAttributes(
Map<String, Object> attributes, Throwable throwable) {
io.opentelemetry.context.Context context =
(io.opentelemetry.context.Context) attributes.remove(CONTEXT_ATTRIBUTE);
finishSpanIfPresent(context, throwable);
}
public static class SpanFinishingSubscriber<T> implements CoreSubscriber<T> { public static class SpanFinishingSubscriber<T> implements CoreSubscriber<T> {
private final CoreSubscriber<? super T> subscriber; private final CoreSubscriber<? super T> subscriber;

View File

@ -127,7 +127,7 @@ public final class ReferenceMatcher {
new Mismatch.MissingClass( new Mismatch.MissingClass(
reference.getSources().toArray(new Source[0]), reference.getClassName())); reference.getSources().toArray(new Source[0]), reference.getClassName()));
} }
return checkMatch(reference, resolution.resolve()); return checkThirdPartyTypeMatch(reference, resolution.resolve());
} }
} catch (Exception e) { } catch (Exception e) {
if (e.getMessage().startsWith("Cannot resolve type description for ")) { if (e.getMessage().startsWith("Cannot resolve type description for ")) {
@ -187,7 +187,8 @@ public final class ReferenceMatcher {
superType -> collectMethodsFromTypeHierarchy(superType, abstractMethods, plainMethods)); superType -> collectMethodsFromTypeHierarchy(superType, abstractMethods, plainMethods));
} }
private static List<Mismatch> checkMatch(Reference reference, TypeDescription typeOnClasspath) { private static List<Mismatch> checkThirdPartyTypeMatch(
Reference reference, TypeDescription typeOnClasspath) {
List<Mismatch> mismatches = Collections.emptyList(); List<Mismatch> mismatches = Collections.emptyList();
for (Reference.Flag flag : reference.getFlags()) { for (Reference.Flag flag : reference.getFlags()) {