From 5c702fff279e0695f692302751fea112dba96e19 Mon Sep 17 00:00:00 2001 From: Imbyungjun Date: Tue, 27 Feb 2024 13:45:27 +0900 Subject: [PATCH] Fix oshi (#1004) --- ngrinder-core/build.gradle | 4 ++-- .../main/java/net/grinder/engine/agent/PropertyBuilder.java | 3 +-- .../main/java/org/ngrinder/common/util/SystemInfoUtils.java | 5 ----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ngrinder-core/build.gradle b/ngrinder-core/build.gradle index 7602dfbb24..0bc1a89fb9 100644 --- a/ngrinder-core/build.gradle +++ b/ngrinder-core/build.gradle @@ -3,7 +3,7 @@ description = "ngrinder-core" dependencies { api (project(":ngrinder-groovy")) api (group: "org.apache.commons", name: "commons-compress", version: "1.4.1") - api (group: "com.github.oshi", name: "oshi-core", version: "6.1.6") + api (group: "com.github.oshi", name: "oshi-core-java11", version: "6.4.13") implementation files("${rootDir}/lib/grinder-3.9.1-patch.jar") implementation (group: "org.pf4j", name: "pf4j", version: "3.0.1") @@ -11,7 +11,7 @@ dependencies { implementation (group: "commons-collections", name: "commons-collections", version: "3.2.1") implementation (group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: jackson_version) implementation (group: "com.fasterxml.jackson.core", name: "jackson-databind", version: jackson_version) - implementation (group: "net.java.dev.jna", name: "jna", version: "5.6.0") + implementation (group: "net.java.dev.jna", name: "jna", version: "5.14.0") implementation (group: "commons-codec", name: "commons-codec", version: "1.14") implementation (group: "com.beust", name: "jcommander", version: "1.32") implementation (group: "ch.qos.logback", name: "logback-classic", version: "1.0.0") diff --git a/ngrinder-core/src/main/java/net/grinder/engine/agent/PropertyBuilder.java b/ngrinder-core/src/main/java/net/grinder/engine/agent/PropertyBuilder.java index 7271b6f5e0..5e6bc2e46c 100644 --- a/ngrinder-core/src/main/java/net/grinder/engine/agent/PropertyBuilder.java +++ b/ngrinder-core/src/main/java/net/grinder/engine/agent/PropertyBuilder.java @@ -40,7 +40,6 @@ import static org.ngrinder.common.util.Preconditions.checkNotEmpty; import static org.ngrinder.common.util.Preconditions.checkNotNull; import static org.ngrinder.common.util.SystemInfoUtils.getAvailableMemory; -import static org.ngrinder.common.util.SystemInfoUtils.getJDKVersion; /** * Class which is responsible to build custom jvm arguments. @@ -205,7 +204,7 @@ public String buildJVMArgumentWithoutMemory() { addAdditionalJavaOpt(jvmArguments); } - String jdkVersion = getJDKVersion(); + String jdkVersion = System.getProperty("java.specification.version"); if (jdkVersion != null && !jdkVersion.startsWith("1.")) { jvmArguments.append(" --add-opens java.base/java.net=ALL-UNNAMED "); } diff --git a/ngrinder-core/src/main/java/org/ngrinder/common/util/SystemInfoUtils.java b/ngrinder-core/src/main/java/org/ngrinder/common/util/SystemInfoUtils.java index 272c8244b3..27ffa714ea 100644 --- a/ngrinder-core/src/main/java/org/ngrinder/common/util/SystemInfoUtils.java +++ b/ngrinder-core/src/main/java/org/ngrinder/common/util/SystemInfoUtils.java @@ -33,7 +33,6 @@ import static com.sun.jna.Platform.isWindows; import static java.lang.System.currentTimeMillis; -import static java.lang.System.getProperty; import static oshi.util.ExecutingCommand.runNative; /** @@ -104,10 +103,6 @@ public static BandWidth getNetworkUsage() { return getBandWidth(rx, tx); } - public static String getJDKVersion() { - return getProperty("java.specification.version"); - } - private static BandWidth getBandWidth(long rx, long tx) { BandWidth bandWidth = new BandWidth(currentTimeMillis()); bandWidth.setReceived(bandWidth.getReceived() + rx);