File tree 2 files changed +12
-26
lines changed
components/cli/src/main/java/datadog.cli
dd-java-agent/src/main/java/datadog/trace/bootstrap
2 files changed +12
-26
lines changed Original file line number Diff line number Diff line change 10
10
import java .util .Arrays ;
11
11
import java .util .Collections ;
12
12
import java .util .HashMap ;
13
- import java .util .HashSet ;
14
13
import java .util .List ;
15
14
import java .util .Map ;
16
- import java .util .Set ;
17
15
18
16
public class CLIHelper {
19
17
public static final CLIHelper ARGS = new CLIHelper ();
@@ -24,16 +22,8 @@ public CLIHelper() {
24
22
this .args = parseJvmArgs (initJvmArgs ());
25
23
}
26
24
27
- public Set <String > getJvmArgs () {
28
- return new HashSet <>(args .keySet ());
29
- }
30
-
31
- public boolean contains (String argument ) {
32
- return args .containsKey (argument );
33
- }
34
-
35
- public List <String > getValues (String key ) {
36
- return args .getOrDefault (key , Collections .emptyList ());
25
+ public List <String > getValues (String jvmArg ) {
26
+ return this .args .get (jvmArg );
37
27
}
38
28
39
29
@ SuppressForbidden
Original file line number Diff line number Diff line change @@ -381,20 +381,16 @@ private static List<File> getAgentFilesFromVMArguments() {
381
381
// - On IBM-based JDKs since at least 1.7
382
382
// This prevents custom log managers from working correctly
383
383
// Use reflection to bypass the loading of the class~
384
- for (final String argument : CLIHelper .ARGS .getJvmArgs ()) {
385
- if (argument .startsWith (JAVA_AGENT_ARGUMENT )) {
386
- int index = argument .indexOf ('=' , JAVA_AGENT_ARGUMENT .length ());
387
- String agentPathname =
388
- argument .substring (
389
- JAVA_AGENT_ARGUMENT .length (), index == -1 ? argument .length () : index );
390
- File agentFile = new File (agentPathname );
391
- if (agentFile .exists () && agentFile .isFile ()) {
392
- agentFiles .add (agentFile );
393
- } else {
394
- System .err .println (
395
- "Could not get bootstrap jar from -javaagent arg: unable to find javaagent file: "
396
- + agentFile );
397
- }
384
+ for (final String argument : CLIHelper .ARGS .getValues (JAVA_AGENT_ARGUMENT )) {
385
+ int index = argument .indexOf ('=' );
386
+ String agentPathname = argument .substring (0 , index == -1 ? argument .length () : index );
387
+ File agentFile = new File (agentPathname );
388
+ if (agentFile .exists () && agentFile .isFile ()) {
389
+ agentFiles .add (agentFile );
390
+ } else {
391
+ System .err .println (
392
+ "Could not get bootstrap jar from -javaagent arg: unable to find javaagent file: "
393
+ + agentFile );
398
394
}
399
395
}
400
396
}
You can’t perform that action at this time.
0 commit comments