Skip to content

Commit

Permalink
RC: Fix setup of jvm.args for 1.0.1 messages (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
kittylyst authored Oct 7, 2024
1 parent 0266b14 commit 4dfcc94
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void generateReport(Filtering masking) {

RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
List<String> inputArguments = fixInputArguments(runtimeMXBean.getInputArguments());
options.put("jvm.args", inputArguments);
options.put("jvm.args", String.join(" ", inputArguments));

MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage();
Expand Down
9 changes: 1 addition & 8 deletions api/src/main/java/com/redhat/insights/reports/Utils.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.reports;

import static java.util.Collections.emptyMap;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public final class Utils {
private Utils() {}

@SuppressWarnings("unchecked")
public static Map<String, Object> defaultMasking(final Map<String, Object> inArgs) {
List<String> jvmArgs = new ArrayList<>();
List<String> args = (List<String>) (inArgs.getOrDefault("jvm.args", emptyMap()));
for (String arg : args) {
jvmArgs.add(sanitizeJavaParameters(arg));
}
String jvmArgs = sanitizeJavaParameters((String) (inArgs.getOrDefault("jvm.args", "")));
inArgs.put("jvm.args", jvmArgs);
String command = (String) inArgs.getOrDefault("java.command", "");
inArgs.put("java.command", sanitizeJavaParameters(command));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void testReportSanitization() throws IOException {
Map<?, ?> basicReport = (Map<?, ?>) parseReport(report).get("basic");

assertEquals(
sanitizedJvmArgs,
String.join(" ", sanitizedJvmArgs.toArray(new String[0])),
basicReport.get("jvm.args"),
"The \"jvm.args\" property in the basic report should be properly sanitized.");
assertEquals(
Expand Down

0 comments on commit 4dfcc94

Please sign in to comment.