Fix potential StackOverFlowError on regexp
This commit is contained in:
parent
660041636a
commit
1e390984c1
|
@ -2,22 +2,22 @@ package datadog.trace.instrumentation.trace_annotation;
|
|||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import datadog.trace.agent.tooling.Instrumenter;
|
||||
import datadog.trace.api.Config;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* TraceConfig Instrumentation does not extend Default.
|
||||
*
|
||||
|
@ -42,16 +42,29 @@ public class TraceConfigInstrumentation implements Instrumenter {
|
|||
+ PACKAGE_CLASS_NAME_REGEX
|
||||
+ "\\["
|
||||
+ METHOD_LIST_REGEX
|
||||
+ "\\]\\s*;?\\s*";
|
||||
+ "\\]";
|
||||
|
||||
private final Map<String, Set<String>> classMethodsToTrace;
|
||||
|
||||
private boolean validateConfigString(String configString) {
|
||||
for (String clazz : configString.split(";")) {
|
||||
if (!clazz.matches(CONFIG_FORMAT)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public TraceConfigInstrumentation() {
|
||||
final String configString = Config.get().getTraceMethods();
|
||||
this(Config.get().getTraceMethods());
|
||||
}
|
||||
|
||||
public TraceConfigInstrumentation(final String configString) {
|
||||
|
||||
if (configString == null || configString.trim().isEmpty()) {
|
||||
classMethodsToTrace = Collections.emptyMap();
|
||||
|
||||
} else if (!configString.matches(CONFIG_FORMAT)) {
|
||||
} else if (!validateConfigString(configString)) {
|
||||
log.warn(
|
||||
"Invalid trace method config '{}'. Must match 'package.Class$Name[method1,method2];*'.",
|
||||
configString);
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue