Migrate from spotbugs to errorprone (#3122)
* Migrate from spotbugs to errorprone * Fix hashtable * try-with-resources * Fix from merge Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This commit is contained in:
parent
35d6bdb730
commit
ed88cca533
|
@ -16,9 +16,13 @@ import org.openjdk.jmh.annotations.Scope;
|
|||
import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.annotations.TearDown;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class HttpBenchmark {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpBenchmark.class);
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
public static class BenchmarkState {
|
||||
@Setup(Level.Trial)
|
||||
|
@ -40,7 +44,7 @@ public class HttpBenchmark {
|
|||
try {
|
||||
jettyServer.stop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.warn("Error", e);
|
||||
} finally {
|
||||
jettyServer.destroy();
|
||||
}
|
||||
|
|
44
build.gradle
44
build.gradle
|
@ -15,7 +15,6 @@ plugins {
|
|||
id "com.github.johnrengelman.shadow" apply false
|
||||
|
||||
id "com.diffplug.spotless"
|
||||
id "com.github.spotbugs" apply false
|
||||
id "net.ltgt.errorprone" apply false
|
||||
id "net.ltgt.nullaway" apply false
|
||||
}
|
||||
|
@ -74,9 +73,47 @@ allprojects {
|
|||
}
|
||||
|
||||
plugins.withId('net.ltgt.errorprone') {
|
||||
plugins.apply('net.ltgt.nullaway')
|
||||
dependencies {
|
||||
errorprone "com.google.errorprone:error_prone_core"
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.errorprone {
|
||||
disableWarningsInGeneratedCode = true
|
||||
excludedPaths = ".*/build/generated/.*"
|
||||
|
||||
// Doesn't work well with Java 8
|
||||
disable("FutureReturnValueIgnored")
|
||||
|
||||
// Require Guava
|
||||
disable("AutoValueImmutableFields")
|
||||
disable("StringSplitter")
|
||||
|
||||
// Great check, but for bytecode manipulation it's too common to separate over
|
||||
// onEnter / onExit
|
||||
// TODO(anuraaga): Only disable for auto instrumentation project.
|
||||
disable("MustBeClosedChecker")
|
||||
|
||||
// Common to avoid an allocation. Revisit if it's worth opt-in suppressing instead of
|
||||
// disabling entirely.
|
||||
disable("MixedMutabilityReturnType")
|
||||
|
||||
// We end up using obsolete types if a library we're instrumenting uses them.
|
||||
disable("JdkObsolete")
|
||||
|
||||
// Storing into a variable in onEnter triggers this unfortunately.
|
||||
// TODO(anuraaga): Only disable for auto instrumentation project.
|
||||
disable("UnusedVariable")
|
||||
|
||||
// TODO(anuraaga): Remove this, we use this pattern in several tests and it will mean
|
||||
// some moving.
|
||||
disable("DefaultPackage")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId('net.ltgt.nullaway') {
|
||||
dependencies {
|
||||
errorprone "com.uber.nullaway:nullaway"
|
||||
}
|
||||
|
||||
|
@ -90,9 +127,6 @@ allprojects {
|
|||
nullaway {
|
||||
severity = net.ltgt.gradle.errorprone.CheckSeverity.ERROR
|
||||
}
|
||||
|
||||
// Doesn't work well with Java 8
|
||||
disable("FutureReturnValueIgnored")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@ import java.time.Duration
|
|||
apply plugin: 'java-library'
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'org.gradle.test-retry'
|
||||
apply plugin: 'net.ltgt.errorprone'
|
||||
|
||||
apply from: "$rootDir/gradle/spotless.gradle"
|
||||
apply from: "$rootDir/gradle/codenarc.gradle"
|
||||
apply from: "$rootDir/gradle/spotbugs.gradle"
|
||||
apply from: "$rootDir/gradle/checkstyle.gradle"
|
||||
|
||||
afterEvaluate {
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<FindBugsFilter>
|
||||
<Match>
|
||||
<!-- Fluent APIs trigger this -->
|
||||
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- forced GC only used in testing -->
|
||||
<Or>
|
||||
<Class name="io.opentelemetry.instrumentation.test.utils.GcUtils"/>
|
||||
<Class name="io.opentelemetry.javaagent.util.GcUtils"/>
|
||||
<Class name="~io.opentelemetry.instrumentation.api.caching.CacheTest.*"/>
|
||||
</Or>
|
||||
<Bug pattern="DM_GC"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- https://github.com/spotbugs/spotbugs/issues/573 kotlin is not well supported (yet) -->
|
||||
<Source name="~.*\.kt"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- final field warnings can be ignored for this test class -->
|
||||
<Class name="~muzzle\.TestClasses.*"/>
|
||||
<Bug pattern="MS_SHOULD_BE_FINAL"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- inner class serialization warning can be ignored for testing purposes -->
|
||||
<Class name="~HttpServletResponseTest\$.*"/>
|
||||
<Bug pattern="SE_BAD_FIELD_INNER_CLASS"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- inner class serialization warning can be ignored for testing purposes -->
|
||||
<Class name="~HttpServletTest\$.*"/>
|
||||
<Bug pattern="SE_BAD_FIELD_INNER_CLASS"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- inner class serialization warning can be ignored for testing purposes -->
|
||||
<Class name="~SpymemcachedTest\$.*"/>
|
||||
<Bug pattern="SE_BAD_FIELD_INNER_CLASS"/>
|
||||
</Match>
|
||||
|
||||
<Match>
|
||||
<!-- writing to static field in a non-static method (clearAllExportedData()) -->
|
||||
<Class name="io.opentelemetry.instrumentation.testing.LibraryTestRunner"/>
|
||||
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
|
||||
</Match>
|
||||
|
||||
</FindBugsFilter>
|
|
@ -1,26 +0,0 @@
|
|||
def isCI = System.getenv("CI") != null
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
|
||||
spotbugs {
|
||||
ignoreFailures = false
|
||||
reportLevel = "high"
|
||||
omitVisitors = ["FindDeadLocalStores"]
|
||||
effort = "max"
|
||||
excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml")
|
||||
}
|
||||
|
||||
// NB: For some reason, SpotBugsTask can't be referenced even when importing it.
|
||||
tasks.withType(VerificationTask).configureEach {
|
||||
if (name.startsWith("spotbugs")) {
|
||||
reports {
|
||||
html.enabled = !isCI
|
||||
xml.enabled = isCI
|
||||
html {
|
||||
stylesheet = 'fancy-hist.xsl'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,6 @@ public class ConfigBuilder {
|
|||
}
|
||||
|
||||
public Config build() {
|
||||
return new AutoValue_Config(allProperties);
|
||||
return Config.create(allProperties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,6 +406,7 @@ public final class RedisCommandSanitizer {
|
|||
try {
|
||||
numberOfKeys = Integer.parseInt(argToString(args.get(1)));
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,11 +60,11 @@ public abstract class BaseTracer {
|
|||
* @deprecated always pass an OpenTelemetry instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseTracer() {
|
||||
protected BaseTracer() {
|
||||
this(GlobalOpenTelemetry.get());
|
||||
}
|
||||
|
||||
public BaseTracer(OpenTelemetry openTelemetry) {
|
||||
protected BaseTracer(OpenTelemetry openTelemetry) {
|
||||
this.tracer = openTelemetry.getTracer(getInstrumentationName(), getVersion());
|
||||
this.propagators = openTelemetry.getPropagators();
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ public abstract class DatabaseClientTracer<CONNECTION, STATEMENT, SANITIZEDSTATE
|
|||
|
||||
protected final NetPeerAttributes netPeerAttributes;
|
||||
|
||||
public DatabaseClientTracer(NetPeerAttributes netPeerAttributes) {
|
||||
protected DatabaseClientTracer(NetPeerAttributes netPeerAttributes) {
|
||||
this.netPeerAttributes = netPeerAttributes;
|
||||
}
|
||||
|
||||
public DatabaseClientTracer(OpenTelemetry openTelemetry, NetPeerAttributes netPeerAttributes) {
|
||||
protected DatabaseClientTracer(OpenTelemetry openTelemetry, NetPeerAttributes netPeerAttributes) {
|
||||
super(openTelemetry);
|
||||
this.netPeerAttributes = netPeerAttributes;
|
||||
}
|
||||
|
|
|
@ -39,11 +39,11 @@ public abstract class HttpServerTracer<REQUEST, RESPONSE, CONNECTION, STORAGE> e
|
|||
|
||||
protected static final String USER_AGENT = "User-Agent";
|
||||
|
||||
public HttpServerTracer() {
|
||||
protected HttpServerTracer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HttpServerTracer(OpenTelemetry openTelemetry) {
|
||||
protected HttpServerTracer(OpenTelemetry openTelemetry) {
|
||||
super(openTelemetry);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.junit.jupiter.api.Test;
|
|||
class CacheTest {
|
||||
|
||||
@Nested
|
||||
@SuppressWarnings("ClassCanBeStatic")
|
||||
class StrongKeys {
|
||||
@Test
|
||||
void unbounded() {
|
||||
|
@ -60,6 +61,7 @@ class CacheTest {
|
|||
}
|
||||
|
||||
@Nested
|
||||
@SuppressWarnings("ClassCanBeStatic")
|
||||
class WeakKeys {
|
||||
@Test
|
||||
void unbounded() {
|
||||
|
|
|
@ -86,7 +86,7 @@ class InstrumenterTest {
|
|||
}
|
||||
}
|
||||
|
||||
class MapGetter implements TextMapGetter<Map<String, String>> {
|
||||
static class MapGetter implements TextMapGetter<Map<String, String>> {
|
||||
|
||||
@Override
|
||||
public Iterable<String> keys(Map<String, String> carrier) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
apply from: "$rootDir/gradle/instrumentation-library.gradle"
|
||||
apply plugin: "net.ltgt.errorprone"
|
||||
apply plugin: "net.ltgt.nullaway"
|
||||
|
||||
dependencies {
|
||||
library "com.linecorp.armeria:armeria:1.3.0"
|
||||
|
|
|
@ -13,7 +13,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -31,8 +30,8 @@ abstract class ApiGatewayProxyRequest {
|
|||
private static boolean xrayPropagationFieldsOnly(Collection<String> fields) {
|
||||
// ugly but faster than typical convert-to-set-and-check-contains-only
|
||||
return (fields.size() == 1)
|
||||
&& (ParentContextExtractor.AWS_TRACE_HEADER_PROPAGATOR_KEY.equalsIgnoreCase(
|
||||
fields.iterator().next()));
|
||||
&& ParentContextExtractor.AWS_TRACE_HEADER_PROPAGATOR_KEY.equalsIgnoreCase(
|
||||
fields.iterator().next());
|
||||
}
|
||||
|
||||
static ApiGatewayProxyRequest forStream(final InputStream source) throws IOException {
|
||||
|
@ -48,10 +47,6 @@ abstract class ApiGatewayProxyRequest {
|
|||
return new CopiedApiGatewayProxyRequest(source);
|
||||
}
|
||||
|
||||
private static boolean nullOrEmpty(List<String> values) {
|
||||
return ((values == null) || values.isEmpty());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Map<String, String> getHeaders() throws IOException {
|
||||
Map<String, String> headers = ofStream(freshStream());
|
||||
|
|
|
@ -65,6 +65,7 @@ final class HttpSpanAttributes {
|
|||
first = false;
|
||||
}
|
||||
} catch (UnsupportedEncodingException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ class HeadersFactoryTest {
|
|||
assertThat(headers.size()).isEqualTo(3);
|
||||
assertThat(headers)
|
||||
.containsOnly(
|
||||
entry("X-B3-TraceId", ("4fd0b6131f19f39af59518d127b0cafe")),
|
||||
entry("X-B3-SpanId", ("0000000000000456")),
|
||||
entry("X-B3-Sampled", ("true")));
|
||||
entry("X-B3-TraceId", "4fd0b6131f19f39af59518d127b0cafe"),
|
||||
entry("X-B3-SpanId", "0000000000000456"),
|
||||
entry("X-B3-Sampled", "true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -34,6 +34,7 @@ final class AwsSdkHttpClientTracer
|
|||
return withClientSpan(parentContext, span);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject(Context context, SdkHttpRequest.Builder builder) {
|
||||
AwsXrayPropagator.getInstance().inject(context, builder, getSetter());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.SQS
|
|||
import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.request;
|
||||
import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.response;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -117,12 +118,14 @@ enum AwsSdkRequest {
|
|||
|
||||
private final AwsSdkRequestType type;
|
||||
private final String requestClass;
|
||||
// Wrap in unmodifiableMap
|
||||
@SuppressWarnings("ImmutableEnumChecker")
|
||||
private final Map<FieldMapping.Type, List<FieldMapping>> fields;
|
||||
|
||||
AwsSdkRequest(AwsSdkRequestType type, String requestClass, FieldMapping... fields) {
|
||||
this.type = type;
|
||||
this.requestClass = requestClass;
|
||||
this.fields = FieldMapping.groupByType(fields);
|
||||
this.fields = Collections.unmodifiableMap(FieldMapping.groupByType(fields));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.awssdk.v2_2;
|
|||
import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.request;
|
||||
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -19,10 +20,12 @@ enum AwsSdkRequestType {
|
|||
request("aws.table.name", "TableName"),
|
||||
request(SemanticAttributes.DB_NAME.getKey(), "TableName"));
|
||||
|
||||
// Wrapping in unmodifiableMap
|
||||
@SuppressWarnings("ImmutableEnumChecker")
|
||||
private final Map<FieldMapping.Type, List<FieldMapping>> fields;
|
||||
|
||||
AwsSdkRequestType(FieldMapping... fieldMappings) {
|
||||
this.fields = FieldMapping.groupByType(fieldMappings);
|
||||
this.fields = Collections.unmodifiableMap(FieldMapping.groupByType(fieldMappings));
|
||||
}
|
||||
|
||||
List<FieldMapping> fields(FieldMapping.Type type) {
|
||||
|
|
|
@ -35,7 +35,6 @@ public class FieldMapperTest {
|
|||
MethodHandleFactory methodHandleFactory = new MethodHandleFactory();
|
||||
Serializer serializer = mock(Serializer.class);
|
||||
FieldMapper underTest = new FieldMapper(serializer, methodHandleFactory);
|
||||
Map<String, Collection<WriteRequest>> items = new HashMap();
|
||||
UpdateTableRequest sdkRequest =
|
||||
UpdateTableRequest.builder()
|
||||
.provisionedThroughput(
|
||||
|
|
|
@ -75,8 +75,8 @@ public final class CouchbaseQuerySanitizer {
|
|||
}
|
||||
// Query is present in Couchbase [2.0.0, 2.2.0)
|
||||
// Statement is present starting from Couchbase 2.1.0
|
||||
if (QUERY_CLASS != null && QUERY_CLASS.isAssignableFrom(query.getClass())
|
||||
|| STATEMENT_CLASS != null && STATEMENT_CLASS.isAssignableFrom(query.getClass())) {
|
||||
if ((QUERY_CLASS != null && QUERY_CLASS.isAssignableFrom(query.getClass()))
|
||||
|| (STATEMENT_CLASS != null && STATEMENT_CLASS.isAssignableFrom(query.getClass()))) {
|
||||
return sanitizeString(query.toString());
|
||||
}
|
||||
// SpatialViewQuery is present starting from Couchbase 2.1.0
|
||||
|
|
|
@ -67,6 +67,8 @@ public class GuavaListenableFutureInstrumentation implements TypeInstrumentation
|
|||
ExecutorInstrumentationUtils.cleanUpOnMethodExit(state, throwable);
|
||||
}
|
||||
|
||||
// Used by muzzle
|
||||
@SuppressWarnings("UnusedMethod")
|
||||
private static void muzzleCheck(final AbstractFuture<?> future) {
|
||||
future.addListener(null, null);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import test.gwt.shared.MessageServiceAsync;
|
|||
public class GreetingEntryPoint implements EntryPoint {
|
||||
private final MessageServiceAsync messageServiceAsync = GWT.create(MessageService.class);
|
||||
|
||||
@Override
|
||||
public void onModuleLoad() {
|
||||
Button greetingButton = new Button("Greeting");
|
||||
greetingButton.addStyleName("greeting.button");
|
||||
|
@ -51,11 +52,13 @@ public class GreetingEntryPoint implements EntryPoint {
|
|||
messageServiceAsync.sendMessage(
|
||||
message,
|
||||
new AsyncCallback<String>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
messageLabel.setText("Error");
|
||||
messageLabel.addStyleName("error.received");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
messageLabel.setText(result);
|
||||
messageLabel.addStyleName("message.received");
|
||||
|
|
|
@ -12,6 +12,7 @@ import test.gwt.shared.MessageService;
|
|||
@SuppressWarnings("serial")
|
||||
public class MessageServiceImpl extends RemoteServiceServlet implements MessageService {
|
||||
|
||||
@Override
|
||||
public String sendMessage(String message) throws IllegalArgumentException {
|
||||
if (message == null || "Error".equals(message)) {
|
||||
throw new IllegalArgumentException();
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Value {
|
|||
return id;
|
||||
}
|
||||
|
||||
private void setId(Long id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Value {
|
|||
return id;
|
||||
}
|
||||
|
||||
private void setId(Long id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Value {
|
|||
return id;
|
||||
}
|
||||
|
||||
private void setId(Long id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Value {
|
|||
return id;
|
||||
}
|
||||
|
||||
private void setId(Long id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import io.opentelemetry.javaagent.tooling.Constants;
|
|||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
|
@ -91,7 +90,7 @@ public class ClassLoaderInstrumentation implements TypeInstrumentation {
|
|||
//noinspection unchecked
|
||||
return (List<String>) methodHandle.invokeExact();
|
||||
} catch (Throwable e) {
|
||||
return Arrays.asList(Constants.BOOTSTRAP_PACKAGE_PREFIXES);
|
||||
return Constants.BOOTSTRAP_PACKAGE_PREFIXES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +113,7 @@ public class ClassLoaderInstrumentation implements TypeInstrumentation {
|
|||
try {
|
||||
return Class.forName(name, false, null);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,14 @@ public class TracingTube extends AbstractFilterTubeImpl {
|
|||
return new TracingTube(this, tubeCloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NextAction processRequest(Packet request) {
|
||||
tracer().startSpan(endpoint, request);
|
||||
|
||||
return super.processRequest(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NextAction processResponse(Packet response) {
|
||||
tracer().end(response);
|
||||
|
||||
|
@ -47,6 +49,7 @@ public class TracingTube extends AbstractFilterTubeImpl {
|
|||
}
|
||||
|
||||
// this is not used for handling exceptions thrown from webservice invocation
|
||||
@Override
|
||||
public NextAction processException(Throwable throwable) {
|
||||
Packet request = null;
|
||||
// we expect this to be called with attached fiber
|
||||
|
|
|
@ -12,9 +12,11 @@ import io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DbSystemValu
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
@ -803,10 +805,12 @@ public enum JdbcConnectionUrlParser {
|
|||
}
|
||||
}
|
||||
|
||||
private final String[] typeKeys;
|
||||
// Wrapped in unmodifiableList
|
||||
@SuppressWarnings("ImmutableEnumChecker")
|
||||
private final List<String> typeKeys;
|
||||
|
||||
JdbcConnectionUrlParser(String... typeKeys) {
|
||||
this.typeKeys = typeKeys;
|
||||
this.typeKeys = Collections.unmodifiableList(Arrays.asList(typeKeys));
|
||||
}
|
||||
|
||||
abstract DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder);
|
||||
|
|
|
@ -81,6 +81,7 @@ public final class MessageWithDestination {
|
|||
try {
|
||||
jmsDestination = message.getJMSDestination();
|
||||
} catch (Exception ignored) {
|
||||
// Ignore
|
||||
}
|
||||
if (jmsDestination == null) {
|
||||
jmsDestination = fallbackDestination;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class JspTracer extends BaseTracer {
|
|||
// normalizing the URL should remove those symbols for readability and consistency
|
||||
try {
|
||||
span.setAttribute(
|
||||
"jsp.requestURL", (new URI(req.getRequestURL().toString())).normalize().toString());
|
||||
"jsp.requestURL", new URI(req.getRequestURL().toString()).normalize().toString());
|
||||
} catch (URISyntaxException e) {
|
||||
LoggerFactory.getLogger(HttpJspPage.class)
|
||||
.warn("Failed to get and normalize request URL: " + e.getMessage());
|
||||
|
|
|
@ -45,11 +45,13 @@ public class KotlinCoroutinesInstrumentationModule extends InstrumentationModule
|
|||
@Override
|
||||
public void transform(TypeTransformer transformer) {
|
||||
transformer.applyAdviceToMethod(
|
||||
(named("launch").or(named("launch$default")))
|
||||
named("launch")
|
||||
.or(named("launch$default"))
|
||||
.and(takesArgument(1, named("kotlin.coroutines.CoroutineContext"))),
|
||||
KotlinCoroutinesInstrumentationModule.class.getName() + "$LaunchAdvice");
|
||||
transformer.applyAdviceToMethod(
|
||||
(named("runBlocking").or(named("runBlocking$default")))
|
||||
named("runBlocking")
|
||||
.or(named("runBlocking$default"))
|
||||
.and(takesArgument(0, named("kotlin.coroutines.CoroutineContext"))),
|
||||
KotlinCoroutinesInstrumentationModule.class.getName() + "$RunBlockingAdvice");
|
||||
}
|
||||
|
|
|
@ -7,16 +7,15 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0;
|
|||
|
||||
import io.lettuce.core.protocol.RedisCommand;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class LettuceInstrumentationUtil {
|
||||
|
||||
public static final String[] NON_INSTRUMENTING_COMMAND_WORDS =
|
||||
new String[] {"SHUTDOWN", "DEBUG", "OOM", "SEGFAULT"};
|
||||
|
||||
public static final Set<String> nonInstrumentingCommands =
|
||||
new HashSet<>(Arrays.asList(NON_INSTRUMENTING_COMMAND_WORDS));
|
||||
private static final Set<String> nonInstrumentingCommands =
|
||||
Collections.unmodifiableSet(
|
||||
new HashSet<>(Arrays.asList("SHUTDOWN", "DEBUG", "OOM", "SEGFAULT")));
|
||||
|
||||
/**
|
||||
* Determines whether a redis command should finish its relevant span early (as soon as tags are
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
apply from: "$rootDir/gradle/instrumentation-library.gradle"
|
||||
apply plugin: "net.ltgt.errorprone"
|
||||
apply plugin: "net.ltgt.nullaway"
|
||||
|
||||
dependencies {
|
||||
library "io.lettuce:lettuce-core:5.1.0.RELEASE"
|
||||
|
|
|
@ -102,7 +102,7 @@ public class LoggingEventInstrumentation implements TypeInstrumentation {
|
|||
}
|
||||
|
||||
// Assume already instrumented event if traceId is present.
|
||||
if (!mdc.contains(TRACE_ID)) {
|
||||
if (!mdc.containsKey(TRACE_ID)) {
|
||||
Span span = InstrumentationContext.get(LoggingEvent.class, Span.class).get(event);
|
||||
if (span != null && span.getSpanContext().isValid()) {
|
||||
SpanContext spanContext = span.getSpanContext();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
apply from: "$rootDir/gradle/instrumentation-library.gradle"
|
||||
apply plugin: "net.ltgt.errorprone"
|
||||
apply plugin: "net.ltgt.nullaway"
|
||||
|
||||
dependencies {
|
||||
library "org.mongodb:mongo-java-driver:3.1.0"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
apply from: "$rootDir/gradle/instrumentation-library.gradle"
|
||||
apply plugin: "net.ltgt.errorprone"
|
||||
apply plugin: "net.ltgt.nullaway"
|
||||
|
||||
dependencies {
|
||||
library "com.squareup.okhttp3:okhttp:3.0.0"
|
||||
|
|
|
@ -33,9 +33,6 @@ public class Bridging {
|
|||
|
||||
private static final Logger log = LoggerFactory.getLogger(Bridging.class);
|
||||
|
||||
// this is just an optimization to save some byte array allocations
|
||||
public static final ThreadLocal<byte[]> BUFFER = new ThreadLocal<>();
|
||||
|
||||
public static Span toApplication(io.opentelemetry.api.trace.Span agentSpan) {
|
||||
if (!agentSpan.getSpanContext().isValid()) {
|
||||
// no need to wrap
|
||||
|
@ -161,13 +158,4 @@ public class Bridging {
|
|||
applicationTraceState.forEach(agentTraceState::put);
|
||||
return agentTraceState.build();
|
||||
}
|
||||
|
||||
private static byte[] getBuffer() {
|
||||
byte[] bytes = BUFFER.get();
|
||||
if (bytes == null) {
|
||||
bytes = new byte[16];
|
||||
BUFFER.set(bytes);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class ApplicationDoubleSumObserver implements DoubleSumObserver {
|
|||
}
|
||||
|
||||
static class AgentResultDoubleSumObserver
|
||||
implements Consumer<io.opentelemetry.api.metrics.DoubleSumObserver.DoubleResult> {
|
||||
implements Consumer<io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult> {
|
||||
|
||||
private final Consumer<DoubleResult> metricUpdater;
|
||||
|
||||
|
@ -29,18 +29,19 @@ class ApplicationDoubleSumObserver implements DoubleSumObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(io.opentelemetry.api.metrics.DoubleSumObserver.DoubleResult result) {
|
||||
public void accept(io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult result) {
|
||||
metricUpdater.accept(new ApplicationResultDoubleSumObserver(result));
|
||||
}
|
||||
}
|
||||
|
||||
static class ApplicationResultDoubleSumObserver implements DoubleResult {
|
||||
|
||||
private final io.opentelemetry.api.metrics.DoubleSumObserver.DoubleResult
|
||||
private final io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult
|
||||
agentResultDoubleSumObserver;
|
||||
|
||||
public ApplicationResultDoubleSumObserver(
|
||||
io.opentelemetry.api.metrics.DoubleSumObserver.DoubleResult agentResultDoubleSumObserver) {
|
||||
io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult
|
||||
agentResultDoubleSumObserver) {
|
||||
this.agentResultDoubleSumObserver = agentResultDoubleSumObserver;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class ApplicationDoubleUpDownSumObserver implements DoubleUpDownSumObserver {
|
|||
}
|
||||
|
||||
static class AgentResultDoubleUpDownSumObserver
|
||||
implements Consumer<io.opentelemetry.api.metrics.DoubleUpDownSumObserver.DoubleResult> {
|
||||
implements Consumer<io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult> {
|
||||
|
||||
private final Consumer<DoubleResult> metricUpdater;
|
||||
|
||||
|
@ -29,18 +29,18 @@ class ApplicationDoubleUpDownSumObserver implements DoubleUpDownSumObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(io.opentelemetry.api.metrics.DoubleUpDownSumObserver.DoubleResult result) {
|
||||
public void accept(io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult result) {
|
||||
metricUpdater.accept(new ApplicationResultDoubleUpDownSumObserver(result));
|
||||
}
|
||||
}
|
||||
|
||||
static class ApplicationResultDoubleUpDownSumObserver implements DoubleResult {
|
||||
|
||||
private final io.opentelemetry.api.metrics.DoubleUpDownSumObserver.DoubleResult
|
||||
private final io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult
|
||||
agentResultDoubleUpDownSumObserver;
|
||||
|
||||
public ApplicationResultDoubleUpDownSumObserver(
|
||||
io.opentelemetry.api.metrics.DoubleUpDownSumObserver.DoubleResult
|
||||
io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult
|
||||
agentResultDoubleUpDownSumObserver) {
|
||||
this.agentResultDoubleUpDownSumObserver = agentResultDoubleUpDownSumObserver;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class ApplicationDoubleValueObserver implements DoubleValueObserver {
|
|||
}
|
||||
|
||||
static class AgentResultDoubleValueObserver
|
||||
implements Consumer<io.opentelemetry.api.metrics.DoubleValueObserver.DoubleResult> {
|
||||
implements Consumer<io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult> {
|
||||
|
||||
private final Consumer<DoubleResult> metricUpdater;
|
||||
|
||||
|
@ -29,18 +29,18 @@ class ApplicationDoubleValueObserver implements DoubleValueObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(io.opentelemetry.api.metrics.DoubleValueObserver.DoubleResult result) {
|
||||
public void accept(io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult result) {
|
||||
metricUpdater.accept(new ApplicationResultDoubleValueObserver(result));
|
||||
}
|
||||
}
|
||||
|
||||
static class ApplicationResultDoubleValueObserver implements DoubleResult {
|
||||
|
||||
private final io.opentelemetry.api.metrics.DoubleValueObserver.DoubleResult
|
||||
private final io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult
|
||||
agentResultDoubleValueObserver;
|
||||
|
||||
public ApplicationResultDoubleValueObserver(
|
||||
io.opentelemetry.api.metrics.DoubleValueObserver.DoubleResult
|
||||
io.opentelemetry.api.metrics.AsynchronousInstrument.DoubleResult
|
||||
agentResultDoubleValueObserver) {
|
||||
this.agentResultDoubleValueObserver = agentResultDoubleValueObserver;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class ApplicationLongSumObserver implements LongSumObserver {
|
|||
}
|
||||
|
||||
static class AgentResultLongSumObserver
|
||||
implements Consumer<io.opentelemetry.api.metrics.LongSumObserver.LongResult> {
|
||||
implements Consumer<io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult> {
|
||||
|
||||
private final Consumer<LongResult> metricUpdater;
|
||||
|
||||
|
@ -29,18 +29,18 @@ class ApplicationLongSumObserver implements LongSumObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(io.opentelemetry.api.metrics.LongSumObserver.LongResult result) {
|
||||
public void accept(io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult result) {
|
||||
metricUpdater.accept(new ApplicationResultLongSumObserver(result));
|
||||
}
|
||||
}
|
||||
|
||||
static class ApplicationResultLongSumObserver implements LongResult {
|
||||
|
||||
private final io.opentelemetry.api.metrics.LongSumObserver.LongResult
|
||||
private final io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult
|
||||
agentResultLongSumObserver;
|
||||
|
||||
public ApplicationResultLongSumObserver(
|
||||
io.opentelemetry.api.metrics.LongSumObserver.LongResult agentResultLongSumObserver) {
|
||||
io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult agentResultLongSumObserver) {
|
||||
this.agentResultLongSumObserver = agentResultLongSumObserver;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class ApplicationLongUpDownSumObserver implements LongUpDownSumObserver {
|
|||
}
|
||||
|
||||
static class AgentResultLongUpDownSumObserver
|
||||
implements Consumer<io.opentelemetry.api.metrics.LongUpDownSumObserver.LongResult> {
|
||||
implements Consumer<io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult> {
|
||||
|
||||
private final Consumer<LongResult> metricUpdater;
|
||||
|
||||
|
@ -29,18 +29,18 @@ class ApplicationLongUpDownSumObserver implements LongUpDownSumObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(io.opentelemetry.api.metrics.LongUpDownSumObserver.LongResult result) {
|
||||
public void accept(io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult result) {
|
||||
metricUpdater.accept(new ApplicationResultLongUpDownSumObserver(result));
|
||||
}
|
||||
}
|
||||
|
||||
static class ApplicationResultLongUpDownSumObserver implements LongResult {
|
||||
|
||||
private final io.opentelemetry.api.metrics.LongUpDownSumObserver.LongResult
|
||||
private final io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult
|
||||
agentResultLongUpDownSumObserver;
|
||||
|
||||
public ApplicationResultLongUpDownSumObserver(
|
||||
io.opentelemetry.api.metrics.LongUpDownSumObserver.LongResult
|
||||
io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult
|
||||
agentResultLongUpDownSumObserver) {
|
||||
this.agentResultLongUpDownSumObserver = agentResultLongUpDownSumObserver;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class ApplicationLongValueObserver implements LongValueObserver {
|
|||
}
|
||||
|
||||
public static class AgentResultLongValueObserver
|
||||
implements Consumer<io.opentelemetry.api.metrics.LongValueObserver.LongResult> {
|
||||
implements Consumer<io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult> {
|
||||
|
||||
private final Consumer<LongResult> metricUpdater;
|
||||
|
||||
|
@ -29,18 +29,19 @@ class ApplicationLongValueObserver implements LongValueObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(io.opentelemetry.api.metrics.LongValueObserver.LongResult result) {
|
||||
public void accept(io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult result) {
|
||||
metricUpdater.accept(new ApplicationResultLongValueObserver(result));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ApplicationResultLongValueObserver implements LongResult {
|
||||
|
||||
private final io.opentelemetry.api.metrics.LongValueObserver.LongResult
|
||||
private final io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult
|
||||
agentResultLongValueObserver;
|
||||
|
||||
public ApplicationResultLongValueObserver(
|
||||
io.opentelemetry.api.metrics.LongValueObserver.LongResult agentResultLongValueObserver) {
|
||||
io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult
|
||||
agentResultLongValueObserver) {
|
||||
this.agentResultLongValueObserver = agentResultLongValueObserver;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ class AbstractMetricsTest {
|
|||
if (metricData.getName().equals(metricName)) {
|
||||
assertThat(metricData.getDescription()).isNotEmpty();
|
||||
assertThat(metricData.getUnit()).isEqualTo(unit);
|
||||
metricData.getDoubleGaugeData().getPoints();
|
||||
List<PointData> points = new ArrayList<>();
|
||||
points.addAll(metricData.getDoubleGaugeData().getPoints());
|
||||
points.addAll(metricData.getDoubleSumData().getPoints());
|
||||
|
|
|
@ -30,12 +30,14 @@ public class PlayTracer extends BaseTracer {
|
|||
// This method was added in Play 2.6.8
|
||||
typedKeyGetUnderlyingCheck = TypedKey.class.getMethod("asScala");
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
// Fallback
|
||||
if (typedKeyGetUnderlyingCheck == null) {
|
||||
try {
|
||||
typedKeyGetUnderlyingCheck = TypedKey.class.getMethod("underlying");
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
typedKeyGetUnderlying = typedKeyGetUnderlyingCheck;
|
||||
|
@ -55,6 +57,7 @@ public class PlayTracer extends BaseTracer {
|
|||
(play.api.libs.typedmap.TypedKey<HandlerDef>)
|
||||
typedKeyGetUnderlying.invoke(Router.Attrs.HANDLER_DEF));
|
||||
} catch (IllegalAccessException | InvocationTargetException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (defOption != null && !defOption.isEmpty()) {
|
||||
|
|
|
@ -62,35 +62,15 @@ public class TracedDelegatingConsumer implements Consumer {
|
|||
public void handleDelivery(
|
||||
String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
|
||||
throws IOException {
|
||||
Context context = null;
|
||||
Scope scope = null;
|
||||
try {
|
||||
context = tracer().startDeliverySpan(queue, envelope, properties, body);
|
||||
scope = context.makeCurrent();
|
||||
Context context = tracer().startDeliverySpan(queue, envelope, properties, body);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.debug("Instrumentation error in tracing consumer", e);
|
||||
} finally {
|
||||
// TODO this is very unusual code structure for this repo
|
||||
// We have to review it
|
||||
try {
|
||||
// Call delegate.
|
||||
delegate.handleDelivery(consumerTag, envelope, properties, body);
|
||||
|
||||
if (context != null) {
|
||||
tracer().end(context);
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
if (context != null) {
|
||||
tracer().endExceptionally(context, throwable);
|
||||
}
|
||||
|
||||
throw throwable;
|
||||
} finally {
|
||||
if (scope != null) {
|
||||
scope.close();
|
||||
}
|
||||
}
|
||||
try (Scope scope = context.makeCurrent()) {
|
||||
// Call delegate.
|
||||
delegate.handleDelivery(consumerTag, envelope, properties, body);
|
||||
tracer().end(context);
|
||||
} catch (Throwable throwable) {
|
||||
tracer().endExceptionally(context, throwable);
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public final class DecoratorFunctions {
|
|||
private final BiConsumer<? super M, ? super Connection> delegate;
|
||||
private final boolean forceParentContext;
|
||||
|
||||
public OnMessageDecorator(
|
||||
protected OnMessageDecorator(
|
||||
BiConsumer<? super M, ? super Connection> delegate, boolean forceParentContext) {
|
||||
this.delegate = delegate;
|
||||
this.forceParentContext = forceParentContext;
|
||||
|
@ -80,7 +80,7 @@ public final class DecoratorFunctions {
|
|||
private abstract static class OnMessageErrorDecorator<M> implements BiConsumer<M, Throwable> {
|
||||
private final BiConsumer<? super M, ? super Throwable> delegate;
|
||||
|
||||
public OnMessageErrorDecorator(BiConsumer<? super M, ? super Throwable> delegate) {
|
||||
protected OnMessageErrorDecorator(BiConsumer<? super M, ? super Throwable> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class RmiServerContextInstrumentation implements TypeInstrumentation {
|
|||
isMethod()
|
||||
.and(isStatic())
|
||||
.and(named("getTarget"))
|
||||
.and((takesArgument(0, named("sun.rmi.transport.ObjectEndpoint")))),
|
||||
.and(takesArgument(0, named("sun.rmi.transport.ObjectEndpoint"))),
|
||||
getClass().getName() + "$ObjectTableAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ public final class RocketMqTracing {
|
|||
return new RocketMqTracingBuilder(openTelemetry);
|
||||
}
|
||||
|
||||
private final boolean captureExperimentalSpanAttributes;
|
||||
private final boolean propagationEnabled;
|
||||
|
||||
private final RocketMqConsumerTracer rocketMqConsumerTracer;
|
||||
|
@ -34,7 +33,6 @@ public final class RocketMqTracing {
|
|||
OpenTelemetry openTelemetry,
|
||||
boolean captureExperimentalSpanAttributes,
|
||||
boolean propagationEnabled) {
|
||||
this.captureExperimentalSpanAttributes = captureExperimentalSpanAttributes;
|
||||
this.propagationEnabled = propagationEnabled;
|
||||
rocketMqConsumerTracer =
|
||||
new RocketMqConsumerTracer(
|
||||
|
|
|
@ -20,10 +20,10 @@ import org.apache.rocketmq.test.util.RandomUtil;
|
|||
public final class BaseConf {
|
||||
public static final String nsAddr;
|
||||
public static final String broker1Addr;
|
||||
protected static String broker1Name;
|
||||
protected static final String clusterName;
|
||||
protected static final NamesrvController namesrvController;
|
||||
protected static final BrokerController brokerController;
|
||||
static String broker1Name;
|
||||
static final String clusterName;
|
||||
static final NamesrvController namesrvController;
|
||||
static final BrokerController brokerController;
|
||||
|
||||
static {
|
||||
System.setProperty(
|
||||
|
|
|
@ -45,7 +45,7 @@ public class IntegrationTestBase {
|
|||
TMPE_FILES.add(file);
|
||||
path = file.getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.warn("Error creating temporary directory.", e);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ package io.opentelemetry.instrumentation.runtimemetrics;
|
|||
|
||||
import io.opentelemetry.api.metrics.AsynchronousInstrument.LongResult;
|
||||
import io.opentelemetry.api.metrics.GlobalMeterProvider;
|
||||
import io.opentelemetry.api.metrics.LongUpDownSumObserver;
|
||||
import io.opentelemetry.api.metrics.Meter;
|
||||
import io.opentelemetry.api.metrics.common.Labels;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
@ -60,17 +59,16 @@ public final class MemoryPools {
|
|||
public static void registerMemoryAreaObservers() {
|
||||
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
|
||||
Meter meter = GlobalMeterProvider.getMeter(MemoryPools.class.getName());
|
||||
final LongUpDownSumObserver areaMetric =
|
||||
meter
|
||||
.longUpDownSumObserverBuilder("runtime.jvm.memory.area")
|
||||
.setDescription("Bytes of a given JVM memory area.")
|
||||
.setUnit("By")
|
||||
.setUpdater(
|
||||
resultLongObserver -> {
|
||||
observeHeap(resultLongObserver, memoryBean.getHeapMemoryUsage());
|
||||
observeNonHeap(resultLongObserver, memoryBean.getNonHeapMemoryUsage());
|
||||
})
|
||||
.build();
|
||||
meter
|
||||
.longUpDownSumObserverBuilder("runtime.jvm.memory.area")
|
||||
.setDescription("Bytes of a given JVM memory area.")
|
||||
.setUnit("By")
|
||||
.setUpdater(
|
||||
resultLongObserver -> {
|
||||
observeHeap(resultLongObserver, memoryBean.getHeapMemoryUsage());
|
||||
observeNonHeap(resultLongObserver, memoryBean.getNonHeapMemoryUsage());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Register only the "pool" observers. */
|
||||
|
|
|
@ -94,6 +94,7 @@ class TracingObserver<T> extends BasicFuseableObserver<T, T> {
|
|||
return MethodHandles.lookup()
|
||||
.findGetter(BasicFuseableObserver.class, fieldName, QueueDisposable.class);
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public class TestServlets {
|
|||
HttpServerTest.controller(
|
||||
endpoint,
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
resp.setContentType("text/plain");
|
||||
resp.setStatus(endpoint.getStatus());
|
||||
|
@ -60,6 +61,7 @@ public class TestServlets {
|
|||
HttpServerTest.controller(
|
||||
endpoint,
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
resp.sendRedirect(endpoint.getBody());
|
||||
return null;
|
||||
|
@ -69,7 +71,7 @@ public class TestServlets {
|
|||
}
|
||||
|
||||
@WebServlet("/error-status")
|
||||
public static class Error extends HttpServlet {
|
||||
public static class ErrorServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void service(HttpServletRequest req, final HttpServletResponse resp) {
|
||||
final HttpServerTest.ServerEndpoint endpoint =
|
||||
|
@ -77,6 +79,7 @@ public class TestServlets {
|
|||
HttpServerTest.controller(
|
||||
endpoint,
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
resp.setContentType("text/plain");
|
||||
resp.sendError(endpoint.getStatus(), endpoint.getBody());
|
||||
|
@ -95,6 +98,7 @@ public class TestServlets {
|
|||
HttpServerTest.controller(
|
||||
endpoint,
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
throw new Exception(endpoint.getBody());
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class Servlet3MappingResolverFactory extends ServletMappingResolverFactor
|
|||
this.servletConfig = servletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getMappings() {
|
||||
String servletName = servletConfig.getServletName();
|
||||
ServletContext servletContext = servletConfig.getServletContext();
|
||||
|
|
|
@ -21,6 +21,7 @@ public class JakartaServletMappingResolverFactory extends ServletMappingResolver
|
|||
this.servletConfig = servletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getMappings() {
|
||||
String servletName = servletConfig.getServletName();
|
||||
ServletContext servletContext = servletConfig.getServletContext();
|
||||
|
|
|
@ -43,7 +43,7 @@ public abstract class ServletHttpServerTracer<REQUEST, RESPONSE>
|
|||
|
||||
private final ServletAccessor<REQUEST, RESPONSE> accessor;
|
||||
|
||||
public ServletHttpServerTracer(ServletAccessor<REQUEST, RESPONSE> accessor) {
|
||||
protected ServletHttpServerTracer(ServletAccessor<REQUEST, RESPONSE> accessor) {
|
||||
this.accessor = accessor;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
|
||||
public abstract class JavaxServletHttpServerTracer<RESPONSE>
|
||||
extends ServletHttpServerTracer<HttpServletRequest, RESPONSE> {
|
||||
public JavaxServletHttpServerTracer(JavaxServletAccessor<RESPONSE> accessor) {
|
||||
protected JavaxServletHttpServerTracer(JavaxServletAccessor<RESPONSE> accessor) {
|
||||
super(accessor);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ public class SpringBatchInstrumentationModule extends InstrumentationModule {
|
|||
super(instrumentationNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
|
||||
// JSR-352 Batch API
|
||||
return hasClassesNamed("org.springframework.batch.core.jsr.launch.JsrJobOperator");
|
||||
|
@ -53,6 +54,7 @@ public class SpringBatchInstrumentationModule extends InstrumentationModule {
|
|||
new JsrChunkProcessorInstrumentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean defaultEnabled() {
|
||||
// TODO: replace this with an experimental flag
|
||||
return false;
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.springframework.batch.core.ChunkListener;
|
|||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
public class TracingChunkExecutionListener implements ChunkListener, Ordered {
|
||||
public final class TracingChunkExecutionListener implements ChunkListener, Ordered {
|
||||
private final ContextStore<ChunkContext, ContextAndScope> executionContextStore;
|
||||
|
||||
public TracingChunkExecutionListener(
|
||||
|
@ -66,7 +66,7 @@ public class TracingChunkExecutionListener implements ChunkListener, Ordered {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return o != null && getClass() == o.getClass();
|
||||
return o instanceof TracingChunkExecutionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.springframework.batch.core.JobExecution;
|
|||
import org.springframework.batch.core.JobExecutionListener;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
public class TracingJobExecutionListener implements JobExecutionListener, Ordered {
|
||||
public final class TracingJobExecutionListener implements JobExecutionListener, Ordered {
|
||||
private final ContextStore<JobExecution, ContextAndScope> executionContextStore;
|
||||
|
||||
public TracingJobExecutionListener(
|
||||
|
@ -54,7 +54,7 @@ public class TracingJobExecutionListener implements JobExecutionListener, Ordere
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return o != null && getClass() == o.getClass();
|
||||
return o instanceof TracingJobExecutionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.springframework.batch.core.StepExecution;
|
|||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
public class TracingStepExecutionListener implements StepExecutionListener, Ordered {
|
||||
public final class TracingStepExecutionListener implements StepExecutionListener, Ordered {
|
||||
private final ContextStore<StepExecution, ContextAndScope> executionContextStore;
|
||||
|
||||
public TracingStepExecutionListener(
|
||||
|
@ -56,7 +56,7 @@ public class TracingStepExecutionListener implements StepExecutionListener, Orde
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return o != null && getClass() == o.getClass();
|
||||
return o instanceof TracingStepExecutionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,6 +61,7 @@ class SpringWebfluxHttpClientTracer
|
|||
try {
|
||||
return (int) RAW_STATUS_CODE.invokeExact(httpResponse);
|
||||
} catch (Throwable ignored) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
// prior to webflux 5.1, the best we can get is HttpStatus enum, which only covers standard
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class CompletionListener<T> {
|
|||
|
||||
private final Context context;
|
||||
|
||||
public CompletionListener(
|
||||
protected CompletionListener(
|
||||
Context parentContext, MemcachedConnection connection, String methodName) {
|
||||
context = tracer().startSpan(parentContext, connection, methodName);
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ public class VertxReactiveWebServer extends AbstractVerticle {
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
private void handleListProducts(RoutingContext routingContext) {
|
||||
Long requestId = extractRequestId(routingContext);
|
||||
attachRequestIdToCurrentSpan(requestId);
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class CallableWrapper implements Callable {
|
|||
public static Callable<?> wrapIfNeeded(Callable<?> task) {
|
||||
// We wrap only lambdas' anonymous classes and if given object has not already been wrapped.
|
||||
// Anonymous classes have '/' in class name which is not allowed in 'normal' classes.
|
||||
if (task.getClass().getName().contains("/") && (!(task instanceof CallableWrapper))) {
|
||||
if (task.getClass().getName().contains("/") && !(task instanceof CallableWrapper)) {
|
||||
log.debug("Wrapping callable task {}", task);
|
||||
return new CallableWrapper(task);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public final class RunnableWrapper implements Runnable {
|
|||
public static Runnable wrapIfNeeded(Runnable task) {
|
||||
// We wrap only lambdas' anonymous classes and if given object has not already been wrapped.
|
||||
// Anonymous classes have '/' in class name which is not allowed in 'normal' classes.
|
||||
if (task.getClass().getName().contains("/") && (!(task instanceof RunnableWrapper))) {
|
||||
if (task.getClass().getName().contains("/") && !(task instanceof RunnableWrapper)) {
|
||||
log.debug("Wrapping runnable task {}", task);
|
||||
return new RunnableWrapper(task);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ public class State {
|
|||
|
||||
public static final ContextStore.Factory<State> FACTORY = State::new;
|
||||
|
||||
// Used by AtomicReferenceFieldUpdater
|
||||
@SuppressWarnings("UnusedVariable")
|
||||
private volatile Context parentContext;
|
||||
|
||||
private State() {}
|
||||
|
|
|
@ -332,6 +332,7 @@ public class AgentClassLoader extends URLClassLoader {
|
|||
this.agentClassLoader = agentClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String resourceName) {
|
||||
// find resource from boot loader
|
||||
URL url = super.getResource(resourceName);
|
||||
|
@ -426,6 +427,7 @@ public class AgentClassLoader extends URLClassLoader {
|
|||
return jarEntry.getSize();
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class InstrumentationModule {
|
|||
* name containing the version should be passed, e.g. {@code instrumented-library-1.0}.
|
||||
* </ul>
|
||||
*/
|
||||
public InstrumentationModule(
|
||||
protected InstrumentationModule(
|
||||
String mainInstrumentationName, String... additionalInstrumentationNames) {
|
||||
this(toList(mainInstrumentationName, additionalInstrumentationNames));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public abstract class InstrumentationModule {
|
|||
*
|
||||
* @see #InstrumentationModule(String, String...)
|
||||
*/
|
||||
public InstrumentationModule(List<String> instrumentationNames) {
|
||||
protected InstrumentationModule(List<String> instrumentationNames) {
|
||||
if (instrumentationNames.isEmpty()) {
|
||||
throw new IllegalArgumentException("InstrumentationModules must be named");
|
||||
}
|
||||
|
|
|
@ -142,6 +142,8 @@ class SafeHasSuperTypeMatcher extends ElementMatcher.Junction.AbstractBase<TypeD
|
|||
*
|
||||
* <p>This wrapper exists to allow getting interfaces even if the lookup on one fails.
|
||||
*/
|
||||
// Private class, let's save the allocation
|
||||
@SuppressWarnings("IterableAndIterator")
|
||||
private static class SafeInterfaceIterator
|
||||
implements Iterator<TypeDefinition>, Iterable<TypeDefinition> {
|
||||
private final TypeDefinition typeDefinition;
|
||||
|
|
|
@ -28,7 +28,6 @@ import io.opentelemetry.javaagent.tooling.matcher.GlobalClassloaderIgnoresMatche
|
|||
import java.lang.instrument.Instrumentation;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
@ -289,8 +288,7 @@ public class AgentInstaller {
|
|||
}
|
||||
|
||||
private static List<String> loadBootstrapPackagePrefixes() {
|
||||
List<String> bootstrapPackages =
|
||||
new ArrayList<>(Arrays.asList(Constants.BOOTSTRAP_PACKAGE_PREFIXES));
|
||||
List<String> bootstrapPackages = new ArrayList<>(Constants.BOOTSTRAP_PACKAGE_PREFIXES);
|
||||
Iterable<BootstrapPackagesProvider> bootstrapPackagesProviders =
|
||||
SafeServiceLoader.load(BootstrapPackagesProvider.class);
|
||||
for (BootstrapPackagesProvider provider : bootstrapPackagesProviders) {
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
|
||||
package io.opentelemetry.javaagent.tooling;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Some useful constants.
|
||||
*
|
||||
|
@ -13,13 +17,14 @@ package io.opentelemetry.javaagent.tooling;
|
|||
public final class Constants {
|
||||
|
||||
/** packages which will be loaded on the bootstrap classloader. */
|
||||
public static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
|
||||
"io.opentelemetry.javaagent.common.exec",
|
||||
"io.opentelemetry.javaagent.slf4j",
|
||||
"io.opentelemetry.javaagent.bootstrap",
|
||||
"io.opentelemetry.javaagent.shaded",
|
||||
"io.opentelemetry.javaagent.instrumentation.api",
|
||||
};
|
||||
public static final List<String> BOOTSTRAP_PACKAGE_PREFIXES =
|
||||
Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
"io.opentelemetry.javaagent.common.exec",
|
||||
"io.opentelemetry.javaagent.slf4j",
|
||||
"io.opentelemetry.javaagent.bootstrap",
|
||||
"io.opentelemetry.javaagent.shaded",
|
||||
"io.opentelemetry.javaagent.instrumentation.api"));
|
||||
|
||||
private Constants() {}
|
||||
}
|
||||
|
|
|
@ -213,6 +213,8 @@ public class HelperInjector implements Transformer {
|
|||
return new ClassInjector.UsingReflection(classLoader).injectRaw(classnameToBytes);
|
||||
}
|
||||
|
||||
// JavaModule.equals doesn't work for some reason
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
private void ensureModuleCanReadHelperModules(JavaModule target) {
|
||||
if (JavaModule.isSupported() && target != JavaModule.UNSUPPORTED && target.isNamed()) {
|
||||
for (WeakReference<Object> helperModuleReference : helperModules) {
|
||||
|
|
|
@ -29,6 +29,7 @@ class RemappingUrlStreamHandler extends URLStreamHandler {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected URLConnection openConnection(URL url) throws IOException {
|
||||
String file = url.getFile();
|
||||
if ("/".equals(file)) {
|
||||
|
|
|
@ -853,6 +853,8 @@ public class FieldBackedProvider implements InstrumentationContextProvider {
|
|||
* Template class used to generate the class that accesses stored context using either key
|
||||
* instance's own injected field or global hash map if field is not available.
|
||||
*/
|
||||
// Called from generated code
|
||||
@SuppressWarnings({"UnusedMethod", "UnusedVariable"})
|
||||
private static final class ContextStoreImplementationTemplate
|
||||
implements ContextStore<Object, Object> {
|
||||
private static final ContextStoreImplementationTemplate INSTANCE =
|
||||
|
|
|
@ -85,8 +85,7 @@ class ReferenceCollectingClassVisitor extends ClassVisitor {
|
|||
*
|
||||
* @return A reference flag with the required level of access.
|
||||
*/
|
||||
private static MinimumVisibilityFlag computeMinimumMethodAccess(
|
||||
Type from, Type to, Type methodType) {
|
||||
private static MinimumVisibilityFlag computeMinimumMethodAccess(Type from, Type to) {
|
||||
if (from.getInternalName().equalsIgnoreCase(to.getInternalName())) {
|
||||
return MinimumVisibilityFlag.PRIVATE_OR_HIGHER;
|
||||
} else {
|
||||
|
@ -387,7 +386,7 @@ class ReferenceCollectingClassVisitor extends ClassVisitor {
|
|||
List<Flag> methodFlags = new ArrayList<>();
|
||||
methodFlags.add(
|
||||
opcode == Opcodes.INVOKESTATIC ? OwnershipFlag.STATIC : OwnershipFlag.NON_STATIC);
|
||||
methodFlags.add(computeMinimumMethodAccess(refSourceType, ownerType, methodType));
|
||||
methodFlags.add(computeMinimumMethodAccess(refSourceType, ownerType));
|
||||
|
||||
addReference(
|
||||
ClassRef.newBuilder(ownerType.getClassName())
|
||||
|
|
|
@ -17,7 +17,6 @@ import io.opentelemetry.javaagent.extension.muzzle.MethodRef;
|
|||
import io.opentelemetry.javaagent.tooling.AgentTooling;
|
||||
import io.opentelemetry.javaagent.tooling.Utils;
|
||||
import io.opentelemetry.javaagent.tooling.muzzle.InstrumentationClassPredicate;
|
||||
import io.opentelemetry.javaagent.tooling.muzzle.matcher.HelperReferenceWrapper.Factory;
|
||||
import io.opentelemetry.javaagent.tooling.muzzle.matcher.HelperReferenceWrapper.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -140,7 +139,8 @@ public final class ReferenceMatcher {
|
|||
private List<Mismatch> checkHelperClassMatch(ClassRef helperClass, TypePool typePool) {
|
||||
List<Mismatch> mismatches = emptyList();
|
||||
|
||||
HelperReferenceWrapper helperWrapper = new Factory(typePool, references).create(helperClass);
|
||||
HelperReferenceWrapper helperWrapper =
|
||||
new HelperReferenceWrapper.Factory(typePool, references).create(helperClass);
|
||||
|
||||
Set<HelperReferenceWrapper.Field> undeclaredFields =
|
||||
helperClass.getFields().stream()
|
||||
|
|
|
@ -71,14 +71,14 @@ class ShadowPackageRenamingTest extends Specification {
|
|||
|
||||
ClassPath bootstrapClasspath = ClassPath.from(IntegrationTestUtils.getBootstrapProxy())
|
||||
Set<String> bootstrapClasses = new HashSet<>()
|
||||
String[] bootstrapPrefixes = IntegrationTestUtils.getBootstrapPackagePrefixes()
|
||||
List<String> bootstrapPrefixes = IntegrationTestUtils.getBootstrapPackagePrefixes()
|
||||
List<String> badBootstrapPrefixes = []
|
||||
for (ClassPath.ClassInfo info : bootstrapClasspath.getAllClasses()) {
|
||||
bootstrapClasses.add(info.getName())
|
||||
// make sure all bootstrap classes can be loaded from system
|
||||
ClassLoader.getSystemClassLoader().loadClass(info.getName())
|
||||
boolean goodPrefix = false
|
||||
for (int i = 0; i < bootstrapPrefixes.length; ++i) {
|
||||
for (int i = 0; i < bootstrapPrefixes.size(); ++i) {
|
||||
if (info.getName().startsWith(bootstrapPrefixes[i])) {
|
||||
goodPrefix = true
|
||||
break
|
||||
|
|
|
@ -28,9 +28,13 @@ import java.util.jar.Attributes;
|
|||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class IntegrationTestUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(IntegrationTestUtils.class);
|
||||
|
||||
/** Returns the classloader the core agent is running on. */
|
||||
public static ClassLoader getAgentClassLoader() {
|
||||
return getAgentFieldClassloader("AGENT_CLASSLOADER");
|
||||
|
@ -129,12 +133,12 @@ public class IntegrationTestUtils {
|
|||
return className.replace('.', '/') + ".class";
|
||||
}
|
||||
|
||||
public static String[] getBootstrapPackagePrefixes() throws Exception {
|
||||
public static List<String> getBootstrapPackagePrefixes() throws Exception {
|
||||
Field f =
|
||||
getAgentClassLoader()
|
||||
.loadClass("io.opentelemetry.javaagent.tooling.Constants")
|
||||
.getField("BOOTSTRAP_PACKAGE_PREFIXES");
|
||||
return (String[]) f.get(null);
|
||||
return (List<String>) f.get(null);
|
||||
}
|
||||
|
||||
private static String getAgentArgument() {
|
||||
|
@ -251,7 +255,7 @@ public class IntegrationTestUtils {
|
|||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.warn("Error gobbling.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ pluginManagement {
|
|||
id "com.diffplug.spotless" version "5.12.4"
|
||||
id 'com.github.ben-manes.versions' version '0.27.0'
|
||||
id "com.github.johnrengelman.shadow" version "6.1.0"
|
||||
id "com.github.spotbugs" version "4.6.0"
|
||||
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
|
||||
id "me.champeau.jmh" version "0.6.4"
|
||||
id "net.ltgt.errorprone" version "1.3.0"
|
||||
|
|
|
@ -501,7 +501,7 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager {
|
|||
int externalPort = extractMappedPort(container, internalPort);
|
||||
|
||||
try {
|
||||
(new Socket("localhost", externalPort)).close();
|
||||
new Socket("localhost", externalPort).close();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(
|
||||
"Socket not listening yet: " + externalPort, e);
|
||||
|
|
|
@ -22,7 +22,7 @@ class AgentTestRunnerTest extends AgentInstrumentationSpecification {
|
|||
setup:
|
||||
final List<String> bootstrapClassesIncorrectlyLoaded = []
|
||||
for (ClassPath.ClassInfo info : getTestClasspath().getAllClasses()) {
|
||||
for (int i = 0; i < Constants.BOOTSTRAP_PACKAGE_PREFIXES.length; ++i) {
|
||||
for (int i = 0; i < Constants.BOOTSTRAP_PACKAGE_PREFIXES.size(); ++i) {
|
||||
if (info.getName().startsWith(Constants.BOOTSTRAP_PACKAGE_PREFIXES[i])) {
|
||||
Class<?> bootstrapClass = Class.forName(info.getName())
|
||||
def loader
|
||||
|
|
|
@ -14,6 +14,8 @@ public class ExceptionUtils {
|
|||
return ExceptionUtils.sneakyThrow0(t);
|
||||
}
|
||||
|
||||
// Exactly what we want
|
||||
@SuppressWarnings("TypeParameterUnusedInFormals")
|
||||
private static <T extends Throwable> T sneakyThrow0(Throwable t) throws T {
|
||||
throw (T) t;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ class PortAllocator {
|
|||
try {
|
||||
socket.close();
|
||||
} catch (IOException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -12,6 +12,7 @@ public class TestHelperClasses {
|
|||
public static class Helper extends HelperSuperClass implements HelperInterface {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ModifiedButNotUsed")
|
||||
public void foo() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(getStr());
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package muzzle;
|
||||
|
||||
@SuppressWarnings("UnusedMethod")
|
||||
public class HelperReferenceWrapperTestClasses {
|
||||
interface Interface1 {
|
||||
void foo();
|
||||
|
|
|
@ -14,11 +14,10 @@ import java.net.URLClassLoader;
|
|||
import java.util.Collections;
|
||||
|
||||
public class MuzzleWeakReferenceTest {
|
||||
/*
|
||||
* Spock holds strong references to all local variables. For weak reference testing we must create our strong references away from Spock in this java class.
|
||||
*
|
||||
* Even returning a WeakReference<ClassLoader> is enough for spock to create a strong ref.
|
||||
*/
|
||||
|
||||
// Spock holds strong references to all local variables. For weak reference testing we must create
|
||||
// our strong references away from Spock in this java class.
|
||||
// Even returning a WeakReference<ClassLoader> is enough for spock to create a strong ref.
|
||||
public static boolean classLoaderRefIsGarbageCollected() throws InterruptedException {
|
||||
ClassLoader loader = new URLClassLoader(new URL[0], null);
|
||||
WeakReference<ClassLoader> clRef = new WeakReference<>(loader);
|
||||
|
|
|
@ -43,6 +43,7 @@ public class TestClasses {
|
|||
return s;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedMethod")
|
||||
private void privateStuff() {}
|
||||
|
||||
protected void protectedMethod() {}
|
||||
|
|
Loading…
Reference in New Issue