Skip to content

Commit

Permalink
[#noissue] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Aug 22, 2023
1 parent 2eaa751 commit 370005a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ClusterKey {
public static ClusterKey parse(String clusterKeyFormat) {
Objects.requireNonNull(clusterKeyFormat, "clusterKeyFormat");

String[] tokens = clusterKeyFormat.split(DELIMITER);
String[] tokens = clusterKeyFormat.split(DELIMITER, 3);
Assert.isTrue(tokens.length == 3, "invalid token.length == 3");
return new ClusterKey(tokens[0], tokens[1], Long.parseLong(tokens[2]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@

import com.navercorp.pinpoint.common.util.Assert;
import com.navercorp.pinpoint.common.util.IdValidateUtils;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -71,10 +70,10 @@ int create(String metricName) {

private boolean checkValidCustomMetricName(String customMetricName) {
try {
String[] split = customMetricName.split("/");
String[] split = customMetricName.split("/", 3);

if (split == null || split.length != 3) {
throw new IllegalArgumentException("customMetricName must consist of {GroupName}/{MetricName}/LabelName} ");
if (split.length != 3) {
throw new IllegalArgumentException("customMetricName must consist of {GroupName}/{MetricName}/LabelName}");
}

for (String eachName : split) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private boolean isLoadedClass(String classname, ClassLoader cl) {

private void parseRequirementList(List<String> packageRequirementList, List<String> packageList, List<String> requirementList) {
for (String packageWithRequirement : packageRequirementList) {
String[] split = packageWithRequirement.split(":");
String[] split = packageWithRequirement.split(":", 2);
if (split.length == 2) {
packageList.add(split[0]);
requirementList.add(split[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private static List<String> extractLibrariesFromSystemClassLoader() {
if (StringUtils.isEmpty(classPath)) {
return Collections.emptyList();
}
final List<String> paths = Arrays.asList(classPath.split(":"));
final String[] paths = classPath.split(":");
return normalizePaths(paths);
}

Expand All @@ -249,8 +249,8 @@ static String normalizePath(String classPath) {
return Paths.get(classPath).toAbsolutePath().normalize().toString();
}

private static List<String> normalizePaths(List<String> classPaths) {
final List<String> result = new ArrayList<>(classPaths.size());
private static List<String> normalizePaths(String... classPaths) {
final List<String> result = new ArrayList<>(classPaths.length);
for (String cp : classPaths) {
result.add(normalizePath(cp));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private static List<String> extractLibrariesFromSystemClassLoader() {
if (StringUtils.isEmpty(classPath)) {
return Collections.emptyList();
}
final List<String> paths = Arrays.asList(classPath.split(":"));
final String[] paths = classPath.split(":");
return normalizePaths(paths);
}

Expand All @@ -221,8 +221,8 @@ static String normalizePath(String classPath) {
return Paths.get(classPath).toAbsolutePath().normalize().toString();
}

private static List<String> normalizePaths(List<String> classPaths) {
final List<String> result = new ArrayList<>(classPaths.size());
private static List<String> normalizePaths(String... classPaths) {
final List<String> result = new ArrayList<>(classPaths.length);
for (String cp : classPaths) {
result.add(normalizePath(cp));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@ private Map<String, List<Artifact>> combination(List<List<List<Artifact>>> group

for (Entry<String, List<Artifact>> subEntry : sub.entrySet()) {
List<Artifact> subArtifacts = subEntry.getValue();
List<Artifact> t = new ArrayList<>(thisArtifacts.size() + subArtifacts.size());
t.addAll(thisArtifacts);
t.addAll(subArtifacts);
List<Artifact> t = union(thisArtifacts, subArtifacts);

result.put(subEntry.getKey(), t);
}
Expand All @@ -395,9 +393,7 @@ private Map<String, List<Artifact>> combination(List<List<List<Artifact>>> group

for (Entry<String, List<Artifact>> subEntry : sub.entrySet()) {
List<Artifact> subArtifacts = subEntry.getValue();
List<Artifact> t = new ArrayList<>(thisArtifacts.size() + subArtifacts.size());
t.addAll(thisArtifacts);
t.addAll(subArtifacts);
List<Artifact> t = union(thisArtifacts, subArtifacts);

String subKey = subEntry.getKey();
String key = subKey.isEmpty() ? thisKey : thisKey + ", " + subKey;
Expand All @@ -410,4 +406,11 @@ private Map<String, List<Artifact>> combination(List<List<List<Artifact>>> group
return result;
}

private static List<Artifact> union(List<Artifact> list1, List<Artifact> list2) {
List<Artifact> lists = new ArrayList<>(list1.size() + list2.size());
lists.addAll(list1);
lists.addAll(list2);
return lists;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Exception read(String exceptionClass, String message, List<String> traceI
}

private StackTraceElement parseStackTraceElement(String stackTraceElement) {
final String[] tokens = stackTraceElement.split(",");
final String[] tokens = stackTraceElement.split(",", 4);
if (tokens.length == 4) {
return new StackTraceElement(tokens[0], tokens[1], tokens[2], Integer.parseInt(tokens[3]));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Artifact toArtifact(String artifactName) {
return null;
}

String[] splitValue = artifactName.split(ARTIFACT_DELIMITER);
String[] splitValue = artifactName.split(ARTIFACT_DELIMITER, 4);
if (ArrayUtils.isEmpty(splitValue)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public List<TestParameter> parse(String[] args) {
continue;
}

String[] testArguments = arg.split("=");
String[] testArguments = arg.split("=", 2);
if (testArguments.length != 2) {
continue;
}
Expand Down

0 comments on commit 370005a

Please sign in to comment.