[gradle][debugger][IDEA-359503] do not append an empty string to the task's JVM args

GitOrigin-RevId: bd45c71d374774d99c9868a60d2aad932320a4f8
This commit is contained in:
Alexander.Glukhov
2024-09-23 12:38:07 +02:00
committed by intellij-monorepo-bot
parent c796e05468
commit e77c74fdd4

View File

@@ -16,11 +16,24 @@ class GradleDebuggerUtil {
}
static List<String> getProcessOptions() {
String options = requireNonNullElse(System.getenv("PROCESS_OPTIONS"), "")
return options.split(", ")
String envValue = requireNonNullElse(System.getenv("PROCESS_OPTIONS"), "")
if (isBlank(envValue)) {
return Collections.emptyList()
}
List<String> options = new ArrayList<>()
for (final def option in envValue.split(", ")) {
if (!isBlank(option)) {
options.add(option.trim())
}
}
return options
}
private static <T> T requireNonNullElse(T object, T fallback) {
return (object != null) ? object : Objects.requireNonNull(fallback, "The fallback value must not be null!")
}
private static boolean isBlank(String value) {
return value == null || value.trim().isEmpty()
}
}