Fix potential StackOverFlowError on regexp (#1193)
Fix potential StackOverFlowError on regexp
This commit is contained in:
commit
8757ba0a81
|
@ -42,16 +42,25 @@ public class TraceConfigInstrumentation implements Instrumenter {
|
||||||
+ PACKAGE_CLASS_NAME_REGEX
|
+ PACKAGE_CLASS_NAME_REGEX
|
||||||
+ "\\["
|
+ "\\["
|
||||||
+ METHOD_LIST_REGEX
|
+ METHOD_LIST_REGEX
|
||||||
+ "\\]\\s*;?\\s*";
|
+ "\\]";
|
||||||
|
|
||||||
private final Map<String, Set<String>> classMethodsToTrace;
|
private final Map<String, Set<String>> classMethodsToTrace;
|
||||||
|
|
||||||
|
private boolean validateConfigString(String configString) {
|
||||||
|
for (String segment : configString.split(";")) {
|
||||||
|
if (!segment.trim().matches(CONFIG_FORMAT)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public TraceConfigInstrumentation() {
|
public TraceConfigInstrumentation() {
|
||||||
final String configString = Config.get().getTraceMethods();
|
final String configString = Config.get().getTraceMethods();
|
||||||
if (configString == null || configString.trim().isEmpty()) {
|
if (configString == null || configString.trim().isEmpty()) {
|
||||||
classMethodsToTrace = Collections.emptyMap();
|
classMethodsToTrace = Collections.emptyMap();
|
||||||
|
|
||||||
} else if (!configString.matches(CONFIG_FORMAT)) {
|
} else if (!validateConfigString(configString)) {
|
||||||
log.warn(
|
log.warn(
|
||||||
"Invalid trace method config '{}'. Must match 'package.Class$Name[method1,method2];*'.",
|
"Invalid trace method config '{}'. Must match 'package.Class$Name[method1,method2];*'.",
|
||||||
configString);
|
configString);
|
||||||
|
|
Loading…
Reference in New Issue