diff --git a/hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/reader/core/TableConfiguration.java b/hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/reader/core/TableConfiguration.java index c60430c02bbc..f98606a9d9d2 100644 --- a/hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/reader/core/TableConfiguration.java +++ b/hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/reader/core/TableConfiguration.java @@ -30,11 +30,11 @@ public String toString() { } }; - private Long maxFileSize; - private Boolean readOnly; - private Boolean compactionEnabled; - private Long memstoreFlushSize; - private Durability durability; + private final Long maxFileSize; + private final Boolean readOnly; + private final Boolean compactionEnabled; + private final Long memstoreFlushSize; + private final Durability durability; public enum Durability { ASYNC_WAL, diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/cache/IdAllocator.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/cache/IdAllocator.java index be73d64df7ce..d0d23efaa448 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/cache/IdAllocator.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/cache/IdAllocator.java @@ -8,7 +8,7 @@ public interface IdAllocator { int allocate(); enum ID_TYPE { - BYPASS, ZIGZAG; + BYPASS, ZIGZAG } class ZigZagAllocator implements IdAllocator { diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorDefinitionFactory.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorDefinitionFactory.java index d64c79a1d45d..85993fa6d8ba 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorDefinitionFactory.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorDefinitionFactory.java @@ -16,10 +16,19 @@ package com.navercorp.pinpoint.profiler.instrument.interceptor; -import com.navercorp.pinpoint.bootstrap.interceptor.*; +import com.navercorp.pinpoint.bootstrap.interceptor.ApiIdAwareAroundInterceptor; +import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor; +import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor0; +import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor1; +import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor2; +import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor3; +import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor4; +import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor5; +import com.navercorp.pinpoint.bootstrap.interceptor.Interceptor; +import com.navercorp.pinpoint.bootstrap.interceptor.StaticAroundInterceptor; import com.navercorp.pinpoint.bootstrap.interceptor.annotation.IgnoreMethod; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.lang.reflect.Method; import java.util.ArrayList; @@ -159,13 +168,13 @@ private InterceptorDefinition createInterceptorDefinition(Class methodInsnList; + private final MethodInsn methodInsn; public LambdaClassJava15() { - this.methodInsnList = Arrays.asList( - new MethodInsn("generateInnerClass", "java/lang/invoke/MethodHandles$Lookup", "defineHiddenClass", DELEGATE_CLASS, "defineHiddenClass", "(Ljava/lang/invoke/MethodHandles$Lookup;[BZ[Ljava/lang/invoke/MethodHandles$Lookup$ClassOption;)Ljava/lang/invoke/MethodHandles$Lookup;")); + this.methodInsn = new MethodInsn("generateInnerClass", + "java/lang/invoke/MethodHandles$Lookup", + "defineHiddenClass", + DELEGATE_CLASS, + "defineHiddenClass", + "(Ljava/lang/invoke/MethodHandles$Lookup;[BZ[Ljava/lang/invoke/MethodHandles$Lookup$ClassOption;)Ljava/lang/invoke/MethodHandles$Lookup;"); } @Override public List getMethodInsnList() { - return methodInsnList; + return Collections.singletonList(methodInsn); } @Override public String toString() { return "LambdaClassJava15{" + - "methodInsnList=" + methodInsnList + + "methodInsn=" + methodInsn + '}'; } } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava16.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava16.java index 1937188d888f..2d0785b86c59 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava16.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava16.java @@ -23,24 +23,33 @@ public class LambdaClassJava16 implements LambdaClass { public static final String DELEGATE_CLASS = "com/navercorp/pinpoint/bootstrap/java16/lambda/MethodHandlesLookupDelegatorJava16"; - private final List methodInsnList; + private final MethodInsn[] methodInsnList; public LambdaClassJava16() { - this.methodInsnList = Arrays.asList( - new MethodInsn("generateInnerClass", "java/lang/invoke/MethodHandles$Lookup", "defineHiddenClass", DELEGATE_CLASS, "defineHiddenClass", "(Ljava/lang/invoke/MethodHandles$Lookup;[BZ[Ljava/lang/invoke/MethodHandles$Lookup$ClassOption;)Ljava/lang/invoke/MethodHandles$Lookup;"), - new MethodInsn("generateInnerClass", "java/lang/invoke/MethodHandles$Lookup", "defineHiddenClassWithClassData", DELEGATE_CLASS, "defineHiddenClassWithClassData", "(Ljava/lang/invoke/MethodHandles$Lookup;[BLjava/lang/Object;Z[Ljava/lang/invoke/MethodHandles$Lookup$ClassOption;)Ljava/lang/invoke/MethodHandles$Lookup;") - ); + final MethodInsn insn1 = new MethodInsn("generateInnerClass", + "java/lang/invoke/MethodHandles$Lookup", + "defineHiddenClass", + DELEGATE_CLASS, + "defineHiddenClass", + "(Ljava/lang/invoke/MethodHandles$Lookup;[BZ[Ljava/lang/invoke/MethodHandles$Lookup$ClassOption;)Ljava/lang/invoke/MethodHandles$Lookup;"); + final MethodInsn insn2 = new MethodInsn("generateInnerClass", + "java/lang/invoke/MethodHandles$Lookup", + "defineHiddenClassWithClassData", + DELEGATE_CLASS, + "defineHiddenClassWithClassData", + "(Ljava/lang/invoke/MethodHandles$Lookup;[BLjava/lang/Object;Z[Ljava/lang/invoke/MethodHandles$Lookup$ClassOption;)Ljava/lang/invoke/MethodHandles$Lookup;"); + this.methodInsnList = new MethodInsn[]{insn1, insn2}; } @Override public List getMethodInsnList() { - return methodInsnList; + return Arrays.asList(methodInsnList); } @Override public String toString() { return "LambdaClassJava16{" + - "methodInsnList=" + methodInsnList + + "methodInsnList=" + Arrays.toString(methodInsnList) + '}'; } } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava8.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava8.java index 945edb9c5ada..cf01eefdc5aa 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava8.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava8.java @@ -16,7 +16,7 @@ package com.navercorp.pinpoint.profiler.instrument.lambda; -import java.util.Arrays; +import java.util.Collections; import java.util.List; /** @@ -26,14 +26,20 @@ public class LambdaClassJava8 implements LambdaClass { public static final String DELEGATE_CLASS = "com/navercorp/pinpoint/bootstrap/lambda/UnsafeDelegatorJava8"; - private final List methodInsnList; + private final MethodInsn methodInsn; public LambdaClassJava8() { - this.methodInsnList = Arrays.asList(new MethodInsn("spinInnerClass", "sun/misc/Unsafe", "defineAnonymousClass", DELEGATE_CLASS, "defineAnonymousClass", null)); + this.methodInsn = new MethodInsn("spinInnerClass", + "sun/misc/Unsafe", + "defineAnonymousClass", + DELEGATE_CLASS, + "defineAnonymousClass", + null); + } @Override public List getMethodInsnList() { - return methodInsnList; + return Collections.singletonList(methodInsn); } } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava9.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava9.java index 4af281f89523..78c3b7314dd3 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava9.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/LambdaClassJava9.java @@ -16,7 +16,7 @@ package com.navercorp.pinpoint.profiler.instrument.lambda; -import java.util.Arrays; +import java.util.Collections; import java.util.List; /** @@ -26,14 +26,19 @@ public class LambdaClassJava9 implements LambdaClass { public static final String DELEGATE_CLASS = "com/navercorp/pinpoint/bootstrap/java9/lambda/UnsafeDelegatorJava9"; - private final List methodInsnList; + private final MethodInsn methodInsn; public LambdaClassJava9() { - this.methodInsnList = Arrays.asList(new MethodInsn("spinInnerClass", "jdk/internal/misc/Unsafe", "defineAnonymousClass", DELEGATE_CLASS, "defineAnonymousClass", null)); + this.methodInsn = new MethodInsn("spinInnerClass", + "jdk/internal/misc/Unsafe", + "defineAnonymousClass", + DELEGATE_CLASS, + "defineAnonymousClass", + null); } @Override public List getMethodInsnList() { - return methodInsnList; + return Collections.singletonList(methodInsn); } } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/MethodInsn.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/MethodInsn.java index 47e866aa9a05..9208a583cd05 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/MethodInsn.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/lambda/MethodInsn.java @@ -19,12 +19,12 @@ import java.util.Objects; public class MethodInsn { - private String methodName; - private String targetClassName; - private String targetMethodName; - private String delegateClassName; - private String delegateMethodName; - private String delegateDescriptor; + private final String methodName; + private final String targetClassName; + private final String targetMethodName; + private final String delegateClassName; + private final String delegateMethodName; + private final String delegateDescriptor; public MethodInsn(String methodName, String targetClassName, String targetMethodName, String delegateClassName, String delegateMethodName, String delegateDescriptor) { this.methodName = Objects.requireNonNull(methodName); diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/jdbc/BindValueConverter.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/jdbc/BindValueConverter.java index 3bf888e03b24..8d2ae380dc8f 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/jdbc/BindValueConverter.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/jdbc/BindValueConverter.java @@ -166,49 +166,47 @@ public String convert(Object value) { return "null"; } - if (Byte.class.isInstance(value)) { + if (value instanceof Byte) { return simpleTypeConverter.convert(value); - } else if (Boolean.class.isInstance(value)) { + } else if (value instanceof Boolean) { return simpleTypeConverter.convert(value); - } else if (Short.class.isInstance(value)) { + } else if (value instanceof Short) { return simpleTypeConverter.convert(value); - } else if (Integer.class.isInstance(value)) { + } else if (value instanceof Integer) { return simpleTypeConverter.convert(value); - } else if (Long.class.isInstance(value)) { + } else if (value instanceof Long) { return simpleTypeConverter.convert(value); - } else if (Float.class.isInstance(value)) { + } else if (value instanceof Float) { return simpleTypeConverter.convert(value); - } else if (Double.class.isInstance(value)) { + } else if (value instanceof Double) { return simpleTypeConverter.convert(value); - } else if (BigDecimal.class.isInstance(value)) { + } else if (value instanceof BigDecimal) { return simpleTypeConverter.convert(value); - } else if (String.class.isInstance(value)) { + } else if (value instanceof String) { // String/NString return simpleTypeConverter.convert(value); - } else if (Date.class.isInstance(value)) { + } else if (value instanceof Date) { return simpleTypeConverter.convert(value); - } else if (Time.class.isInstance(value)) { + } else if (value instanceof Time) { return simpleTypeConverter.convert(value); - } else if (Timestamp.class.isInstance(value)) { + } else if (value instanceof Timestamp) { return simpleTypeConverter.convert(value); - } else if (URL.class.isInstance(value)) { + } else if (value instanceof URL) { return simpleTypeConverter.convert(value); - } else if (Ref.class.isInstance(value)) { + } else if (value instanceof Ref) { return simpleTypeConverter.convert(value); - } else if (InputStream.class.isInstance(value)) { + } else if (value instanceof InputStream) { return classNameConverter.convert(value); - } else if (Reader.class.isInstance(value)) { + } else if (value instanceof Reader) { return classNameConverter.convert(value); - } else if (Array.class.isInstance(value)) { + } else if (value instanceof Array) { return classNameConverter.convert(value); - } else if (SQLXML.class.isInstance(value)) { + } else if (value instanceof SQLXML) { return classNameConverter.convert(value); - } else if (byte[].class.isInstance(value)) { + } else if (value instanceof byte[]) { return hexBytesConverter.convert(value); - } else if (Object.class.isInstance(value)) { - return objectConverter.convert(value); } - return ""; + return objectConverter.convert(value); } } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java index 40e00f701b90..19dc86ca7f37 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java @@ -17,8 +17,6 @@ package com.navercorp.pinpoint.profiler.sender; -import java.util.Objects; - import com.navercorp.pinpoint.common.util.Assert; import com.navercorp.pinpoint.common.util.StringUtils; import com.navercorp.pinpoint.io.request.Message; @@ -36,15 +34,16 @@ import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer; import com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory; import com.navercorp.pinpoint.thrift.util.SerializationUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.thrift.TBase; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.util.HashedWheelTimer; import org.jboss.netty.util.Timeout; import org.jboss.netty.util.Timer; import org.jboss.netty.util.TimerTask; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; +import java.util.Objects; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -81,7 +80,7 @@ public class TcpDataSender implements EnhancedDataSender { public TcpDataSender(String name, String host, int port, PinpointClientFactory clientFactory) { this(name, ClientFactoryUtils.newPinpointClientProvider(host, port, clientFactory), - (MessageSerializer) newDefaultMessageSerializer(), DEFAULT_QUEUE_SIZE); + newDefaultMessageSerializer(), DEFAULT_QUEUE_SIZE); } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StatGrpcDataSender.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StatGrpcDataSender.java index 59831c038ab9..3172f6a6edc5 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StatGrpcDataSender.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StatGrpcDataSender.java @@ -19,7 +19,6 @@ import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import java.util.Objects; import com.navercorp.pinpoint.grpc.client.ChannelFactory; import com.navercorp.pinpoint.grpc.trace.PAgentStat; import com.navercorp.pinpoint.grpc.trace.PAgentStatBatch; @@ -35,6 +34,8 @@ import com.navercorp.pinpoint.profiler.util.NamedRunnable; import io.grpc.stub.ClientCallStreamObserver; +import java.util.Objects; + import static com.navercorp.pinpoint.grpc.MessageFormatUtils.debugLog; /** @@ -101,7 +102,7 @@ public StatGrpcDataSender(String host, int port, super(host, port, executorQueueSize, messageConverter, channelFactory); this.reconnectExecutor = Objects.requireNonNull(reconnectExecutor, "reconnectExecutor"); - final Runnable reconnectJob = new NamedRunnable(this.ID) { + final Runnable reconnectJob = new NamedRunnable(ID) { @Override public void run() { startStream(); diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/LocalTraceTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/id/LocalTraceTest.java similarity index 92% rename from profiler/src/test/java/com/navercorp/pinpoint/profiler/context/LocalTraceTest.java rename to profiler/src/test/java/com/navercorp/pinpoint/profiler/context/id/LocalTraceTest.java index dd09ac4ce136..aca552faf47c 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/LocalTraceTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/id/LocalTraceTest.java @@ -1,11 +1,12 @@ -package com.navercorp.pinpoint.profiler.context; +package com.navercorp.pinpoint.profiler.context.id; import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder; import com.navercorp.pinpoint.bootstrap.context.SpanRecorder; import com.navercorp.pinpoint.bootstrap.context.Trace; +import com.navercorp.pinpoint.profiler.context.DisableAsyncChildTrace; +import com.navercorp.pinpoint.profiler.context.DisableTrace; +import com.navercorp.pinpoint.profiler.context.LocalAsyncId; import com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle; -import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot; -import com.navercorp.pinpoint.profiler.context.id.TraceRoot; import com.navercorp.pinpoint.profiler.context.storage.UriStatStorage; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test;