diff --git a/agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/util/spring/StringUtils.java b/agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/util/spring/StringUtils.java
index 34b0f4793405..b6ca8f4fcce4 100644
--- a/agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/util/spring/StringUtils.java
+++ b/agent-module/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/util/spring/StringUtils.java
@@ -46,6 +46,8 @@
*/
class StringUtils {
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
/**
* Check whether the given {@code CharSequence} contains actual text.
*
More specifically, this method returns {@code true} if the
@@ -149,7 +151,7 @@ public static String[] tokenizeToStringArray(
if (trimTokens) {
token = token.trim();
}
- if (!ignoreEmptyTokens || token.length() > 0) {
+ if (!ignoreEmptyTokens || !token.isEmpty()) {
tokens.add(token);
}
}
@@ -168,7 +170,7 @@ public static String[] toStringArray(Collection collection) {
if (collection == null) {
return null;
}
- return collection.toArray(new String[0]);
+ return collection.toArray(EMPTY_STRING_ARRAY);
}
}
diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java
index 36d22fd7c381..9d19aa7bb55e 100644
--- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java
+++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java
@@ -95,6 +95,8 @@ protected void pollTimeout(long timeout) {
static class UriStatConsumer implements MultiConsumer {
+ private final UriStatInfo[] uriStatInfos = new UriStatInfo[0];
+
private static final int DEFAULT_COLLECT_INTERVAL = 30000; // 30s
private static final int SNAPSHOT_LIMIT = 4;
@@ -126,9 +128,9 @@ public void acceptN(Collection messageList) {
AgentUriStatData agentUriStatData = snapshotManager.getCurrent(currentBaseTimestamp);
- Object[] dataList = messageList.toArray();
+ UriStatInfo[] dataList = messageList.toArray(uriStatInfos);
for (int i = 0; i < CollectionUtils.nullSafeSize(messageList); i++) {
- addUriData(agentUriStatData, (UriStatInfo) dataList[i]);
+ addUriData(agentUriStatData, dataList[i]);
}
}
diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMClassNodeAdapter.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMClassNodeAdapter.java
index 54e710aec467..fe48d42478ac 100644
--- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMClassNodeAdapter.java
+++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMClassNodeAdapter.java
@@ -114,6 +114,8 @@ private static byte[] readStream(String classPath, ClassInputStreamProvider plug
return null;
}
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
private final ClassInputStreamProvider pluginInputStreamProvider;
private final ClassLoader classLoader;
private final ProtectionDomain protectionDomain;
@@ -167,7 +169,7 @@ public boolean isAnnotation() {
public String[] getInterfaceNames() {
final List interfaces = this.classNode.interfaces;
if (CollectionUtils.isEmpty(interfaces)) {
- return new String[0];
+ return EMPTY_STRING_ARRAY;
}
final List list = new ArrayList<>(interfaces.size());
@@ -177,7 +179,7 @@ public String[] getInterfaceNames() {
}
}
- return list.toArray(new String[0]);
+ return list.toArray(EMPTY_STRING_ARRAY);
}
public ASMMethodNodeAdapter getDeclaredMethod(final String methodName, final String desc) {
@@ -377,7 +379,7 @@ private String[] getSuperMethodExceptions(ASMMethodNodeAdapter superMethodNode)
if (superMethodNodeExceptions == null) {
return null;
}
- return superMethodNodeExceptions.toArray(new String[0]);
+ return superMethodNodeExceptions.toArray(EMPTY_STRING_ARRAY);
}
public void addGetterMethod(final String methodName, final ASMFieldNodeAdapter fieldNode) {
diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/plugin/PinpointProfilerPackageFilter.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/plugin/PinpointProfilerPackageFilter.java
index 81792082ec01..ff2f2ec0762e 100644
--- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/plugin/PinpointProfilerPackageFilter.java
+++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/plugin/PinpointProfilerPackageFilter.java
@@ -16,9 +16,6 @@
package com.navercorp.pinpoint.profiler.plugin;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -28,9 +25,6 @@
*/
public class PinpointProfilerPackageFilter implements ClassNameFilter {
- private final Logger logger = LogManager.getLogger(this.getClass());
- private final boolean debug = logger.isDebugEnabled();
-
private final String[] packageList;
public PinpointProfilerPackageFilter() {
diff --git a/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java b/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java
index bfb79bda8a08..40d28d65080d 100644
--- a/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java
+++ b/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java
@@ -38,6 +38,8 @@
*/
public class ParallelResultScanner implements ResultScanner {
+ private static final Result[] RESULT_EMPTY_ARRAY = {};
+
private final AbstractRowKeyDistributor keyDistributor;
private final List scanTasks;
private final Result[] nextResults;
@@ -154,7 +156,7 @@ public Result[] next(int nbRows) throws IOException {
break;
}
}
- return resultSets.toArray(new Result[0]);
+ return resultSets.toArray(RESULT_EMPTY_ARRAY);
}
@Override
diff --git a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/util/InetAddressUtils.java b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/util/InetAddressUtils.java
index 06306f811cf7..9ebc9957f82b 100644
--- a/commons-server/src/main/java/com/navercorp/pinpoint/common/server/util/InetAddressUtils.java
+++ b/commons-server/src/main/java/com/navercorp/pinpoint/common/server/util/InetAddressUtils.java
@@ -16,9 +16,9 @@
package com.navercorp.pinpoint.common.server.util;
+import com.google.common.net.InetAddresses;
import com.navercorp.pinpoint.common.util.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
-import com.google.common.net.InetAddresses;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -36,7 +36,7 @@ public static List toInetAddressList(List addressList) {
if (CollectionUtils.isEmpty(addressList)) {
return Collections.emptyList();
}
- final List inetAddressList = new ArrayList(addressList.size());
+ final List inetAddressList = new ArrayList<>(addressList.size());
for (String ignoreAddress : addressList) {
if (StringUtils.isBlank(ignoreAddress)) {
continue;
diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/ObjectUtils.java b/commons/src/main/java/com/navercorp/pinpoint/common/util/ObjectUtils.java
deleted file mode 100644
index fb2e87372cce..000000000000
--- a/commons/src/main/java/com/navercorp/pinpoint/common/util/ObjectUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2023 NAVER Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.navercorp.pinpoint.common.util;
-
-/**
- * @author minwoo.jung
- */
-public class ObjectUtils {
-
- public static T defaultIfNull(T object, T defaultValue) {
- return object != null ? object : defaultValue;
- }
-}
diff --git a/commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/FutureUtils.java b/commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/FutureUtils.java
index 652f9e6d34da..1af0b6857c0a 100644
--- a/commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/FutureUtils.java
+++ b/commons/src/main/java/com/navercorp/pinpoint/common/util/concurrent/FutureUtils.java
@@ -8,6 +8,9 @@
import java.util.function.Supplier;
public final class FutureUtils {
+
+ private static final CompletableFuture>[] FUTURE_EMPTY_ARRAY =new CompletableFuture>[0];
+
private FutureUtils() {
}
@@ -45,7 +48,7 @@ public static Throwable unwrapCompletionException(Throwable error) {
public static List allOf(List> futures) {
Objects.requireNonNull(futures, "futures");
- CompletableFuture[] futuresArray = (CompletableFuture[]) futures.toArray(new CompletableFuture>[0]);
+ CompletableFuture[] futuresArray = (CompletableFuture[]) futures.toArray(FUTURE_EMPTY_ARRAY);
return allOf(futuresArray);
}
@@ -64,7 +67,7 @@ public static List allOf(CompletableFuture[] futures) {
public static CompletableFuture> allOfAsync(List> futures) {
Objects.requireNonNull(futures, "futures");
- final CompletableFuture[] futuresArray = (CompletableFuture[]) futures.toArray(new CompletableFuture>[0]);
+ final CompletableFuture[] futuresArray = (CompletableFuture[]) futures.toArray(FUTURE_EMPTY_ARRAY);
return allOfAsync(futuresArray);
}
diff --git a/inspector-module/inspector-web/src/main/java/com/navercorp/pinpoint/inspector/web/definition/MetricDefinition.java b/inspector-module/inspector-web/src/main/java/com/navercorp/pinpoint/inspector/web/definition/MetricDefinition.java
index dcbe3855b995..1944dfd9f502 100644
--- a/inspector-module/inspector-web/src/main/java/com/navercorp/pinpoint/inspector/web/definition/MetricDefinition.java
+++ b/inspector-module/inspector-web/src/main/java/com/navercorp/pinpoint/inspector/web/definition/MetricDefinition.java
@@ -18,7 +18,6 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.navercorp.pinpoint.common.util.ObjectUtils;
import com.navercorp.pinpoint.inspector.web.definition.metric.EmptyPostProcessor;
import com.navercorp.pinpoint.inspector.web.definition.metric.EmptyPreProcessor;
import com.navercorp.pinpoint.inspector.web.definition.metric.field.Field;
@@ -54,9 +53,9 @@ public MetricDefinition(@JsonProperty("definitionId") String definitionId,
this.definitionId = Objects.requireNonNull(definitionId, "definitionId");
this.metricName = Objects.requireNonNull(metricName, "metricName");
this.title = Objects.requireNonNull(title, "title");
- this.groupingRule = ObjectUtils.defaultIfNull(groupingRule, GroupingRule.UNKNOWN);
- this.preProcess = Objects.toString(preProcess, EmptyPreProcessor.INSTANCE.getName());
- this.postProcess = Objects.toString(postProcess, EmptyPostProcessor.INSTANCE.getName());
+ this.groupingRule = Objects.requireNonNullElse(groupingRule, GroupingRule.UNKNOWN);
+ this.preProcess = Objects.requireNonNullElse(preProcess, EmptyPreProcessor.INSTANCE.getName());
+ this.postProcess = Objects.requireNonNullElse(postProcess, EmptyPostProcessor.INSTANCE.getName());
this.fields = Objects.requireNonNull(fields, "fields");
}