Skip to content

Commit 5421f09

Browse files
committed
simplify JVM params generation
1 parent 187ca89 commit 5421f09

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TargetSystemIntegrationTest.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
import java.util.ArrayList;
2323
import java.util.Arrays;
2424
import java.util.Collection;
25-
import java.util.HashMap;
2625
import java.util.List;
27-
import java.util.Map;
2826
import java.util.concurrent.BlockingQueue;
2927
import java.util.concurrent.ExecutionException;
3028
import java.util.concurrent.LinkedBlockingDeque;
@@ -200,25 +198,13 @@ public void export(
200198
}
201199

202200
protected static String genericJmxJvmArguments(int port) {
203-
Map<String, Object> args = new HashMap<>();
204-
args.put("com.sun.management.jmxremote.local.only", "false");
205-
args.put("com.sun.management.jmxremote.authenticate", "false");
206-
args.put("com.sun.management.jmxremote.ssl", "false");
207-
args.put("com.sun.management.jmxremote.port", port);
208-
args.put("com.sun.management.jmxremote.rmi.port", port);
209-
List<String> list =
210-
args.entrySet().stream()
211-
.map((e) -> toJvmArg(e.getKey(), e.getValue()))
212-
.collect(Collectors.toList());
213-
return String.join(" ", list);
201+
return "-Dcom.sun.management.jmxremote.local.only=false"
202+
+ " -Dcom.sun.management.jmxremote.authenticate=false"
203+
+ " -Dcom.sun.management.jmxremote.ssl=false"
204+
+ " -Dcom.sun.management.jmxremote.port="
205+
+ port
206+
+ " -Dcom.sun.management.jmxremote.rmi.port="
207+
+ port;
214208
}
215209

216-
private static String toJvmArg(String key, Object value) {
217-
StringBuilder sb = new StringBuilder();
218-
sb.append("-D").append(key);
219-
if (value != null) {
220-
sb.append("=").append(value);
221-
}
222-
return sb.toString();
223-
}
224210
}

0 commit comments

Comments
 (0)