File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +12
-26
lines changed Original file line number Diff line number Diff line change 1010import java .util .Arrays ;
1111import java .util .Collections ;
1212import java .util .HashMap ;
13- import java .util .HashSet ;
1413import java .util .List ;
1514import java .util .Map ;
16- import java .util .Set ;
1715
1816public class CLIHelper {
1917 public static final CLIHelper ARGS = new CLIHelper ();
@@ -24,16 +22,8 @@ public CLIHelper() {
2422 this .args = parseJvmArgs (initJvmArgs ());
2523 }
2624
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 );
3727 }
3828
3929 @ SuppressForbidden
Original file line number Diff line number Diff line change @@ -381,20 +381,16 @@ private static List<File> getAgentFilesFromVMArguments() {
381381 // - On IBM-based JDKs since at least 1.7
382382 // This prevents custom log managers from working correctly
383383 // 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 );
398394 }
399395 }
400396 }
You can’t perform that action at this time.
0 commit comments