Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
*/
class StringUtils {

private static final String[] EMPTY_STRING_ARRAY = new String[0];

/**
* Check whether the given {@code CharSequence} contains actual <em>text</em>.
* <p>More specifically, this method returns {@code true} if the
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -168,7 +170,7 @@ public static String[] toStringArray(Collection<String> collection) {
if (collection == null) {
return null;
}
return collection.toArray(new String[0]);
return collection.toArray(EMPTY_STRING_ARRAY);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@

static class UriStatConsumer implements MultiConsumer<UriStatInfo> {

private final UriStatInfo[] uriStatInfos = new UriStatInfo[0];

private static final int DEFAULT_COLLECT_INTERVAL = 30000; // 30s

private static final int SNAPSHOT_LIMIT = 4;
Expand Down Expand Up @@ -126,9 +128,9 @@

AgentUriStatData agentUriStatData = snapshotManager.getCurrent(currentBaseTimestamp);

Object[] dataList = messageList.toArray();
UriStatInfo[] dataList = messageList.toArray(uriStatInfos);

Check warning on line 131 in agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java

View check run for this annotation

Codecov / codecov/patch

agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java#L131

Added line #L131 was not covered by tests
for (int i = 0; i < CollectionUtils.nullSafeSize(messageList); i++) {
addUriData(agentUriStatData, (UriStatInfo) dataList[i]);
addUriData(agentUriStatData, dataList[i]);

Check warning on line 133 in agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java

View check run for this annotation

Codecov / codecov/patch

agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/storage/AsyncQueueingUriStatStorage.java#L133

Added line #L133 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -167,7 +169,7 @@ public boolean isAnnotation() {
public String[] getInterfaceNames() {
final List<String> interfaces = this.classNode.interfaces;
if (CollectionUtils.isEmpty(interfaces)) {
return new String[0];
return EMPTY_STRING_ARRAY;
}

final List<String> list = new ArrayList<>(interfaces.size());
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
*/
public class ParallelResultScanner implements ResultScanner {

private static final Result[] RESULT_EMPTY_ARRAY = {};

Check warning on line 41 in commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java

View check run for this annotation

Codecov / codecov/patch

commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java#L41

Added line #L41 was not covered by tests

private final AbstractRowKeyDistributor keyDistributor;
private final List<ScanTask> scanTasks;
private final Result[] nextResults;
Expand Down Expand Up @@ -154,7 +156,7 @@
break;
}
}
return resultSets.toArray(new Result[0]);
return resultSets.toArray(RESULT_EMPTY_ARRAY);

Check warning on line 159 in commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java

View check run for this annotation

Codecov / codecov/patch

commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/parallel/ParallelResultScanner.java#L159

Added line #L159 was not covered by tests
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +36,7 @@ public static List<InetAddress> toInetAddressList(List<String> addressList) {
if (CollectionUtils.isEmpty(addressList)) {
return Collections.emptyList();
}
final List<InetAddress> inetAddressList = new ArrayList<InetAddress>(addressList.size());
final List<InetAddress> inetAddressList = new ArrayList<>(addressList.size());
for (String ignoreAddress : addressList) {
if (StringUtils.isBlank(ignoreAddress)) {
continue;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}

Expand Down Expand Up @@ -45,7 +48,7 @@ public static Throwable unwrapCompletionException(Throwable error) {
public static <T> List<T> allOf(List<CompletableFuture<T>> futures) {
Objects.requireNonNull(futures, "futures");

CompletableFuture<T>[] futuresArray = (CompletableFuture<T>[]) futures.toArray(new CompletableFuture<?>[0]);
CompletableFuture<T>[] futuresArray = (CompletableFuture<T>[]) futures.toArray(FUTURE_EMPTY_ARRAY);
return allOf(futuresArray);
}

Expand All @@ -64,7 +67,7 @@ public static <T> List<T> allOf(CompletableFuture<T>[] futures) {
public static <T> CompletableFuture<List<T>> allOfAsync(List<CompletableFuture<T>> futures) {
Objects.requireNonNull(futures, "futures");

final CompletableFuture<T>[] futuresArray = (CompletableFuture<T>[]) futures.toArray(new CompletableFuture<?>[0]);
final CompletableFuture<T>[] futuresArray = (CompletableFuture<T>[]) futures.toArray(FUTURE_EMPTY_ARRAY);
return allOfAsync(futuresArray);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,9 +53,9 @@
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());

Check warning on line 58 in inspector-module/inspector-web/src/main/java/com/navercorp/pinpoint/inspector/web/definition/MetricDefinition.java

View check run for this annotation

Codecov / codecov/patch

inspector-module/inspector-web/src/main/java/com/navercorp/pinpoint/inspector/web/definition/MetricDefinition.java#L56-L58

Added lines #L56 - L58 were not covered by tests
Comment on lines +57 to +58
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Ensure that switching from ObjectUtils.defaultIfNull (which applied a toString conversion for non-null values in preProcess and postProcess) to Objects.requireNonNullElse preserves the intended behavior for these fields.

Suggested change
this.preProcess = Objects.requireNonNullElse(preProcess, EmptyPreProcessor.INSTANCE.getName());
this.postProcess = Objects.requireNonNullElse(postProcess, EmptyPostProcessor.INSTANCE.getName());
this.preProcess = Objects.requireNonNullElse(preProcess != null ? preProcess.toString() : null, EmptyPreProcessor.INSTANCE.getName());
this.postProcess = Objects.requireNonNullElse(postProcess != null ? postProcess.toString() : null, EmptyPostProcessor.INSTANCE.getName());

Copilot uses AI. Check for mistakes.
this.fields = Objects.requireNonNull(fields, "fields");
}

Expand Down