diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 13b3bc07aa..6337ec9797 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -35,6 +35,7 @@ Use subheadings with the "=====" level for adding notes for unreleased changes: ===== Bug fixes * Prevent NPE in OpenTelemetry metrics bridge in case of asynchronous agent start - {pull}3880[#3880] * Fix random Weblogic ClassNotFoundException related to thread context classloader - {pull}3870[#3870] +* Skips using NOFOLLOW_LINKS file open option when running on OS/400 as it's unsupported there - {pull}3905[#3905] [[release-notes-1.x]] === Java Agent version 1.x diff --git a/apm-agent-common/src/main/java/co/elastic/apm/agent/common/JvmRuntimeInfo.java b/apm-agent-common/src/main/java/co/elastic/apm/agent/common/JvmRuntimeInfo.java index d1b905b95a..8ddd83ee6b 100644 --- a/apm-agent-common/src/main/java/co/elastic/apm/agent/common/JvmRuntimeInfo.java +++ b/apm-agent-common/src/main/java/co/elastic/apm/agent/common/JvmRuntimeInfo.java @@ -39,6 +39,7 @@ public class JvmRuntimeInfo { private final boolean isHpUx; private final boolean isCoretto; private final boolean isZos; + private final boolean isOs400; public static JvmRuntimeInfo ofCurrentVM() { return CURRENT_VM; @@ -68,6 +69,7 @@ private JvmRuntimeInfo(String version, String vmName, String vendorName, @Nullab isHpUx = version.endsWith("-hp-ux"); isCoretto = vendorName != null && vendorName.contains("Amazon"); isZos = (osName != null) && osName.toLowerCase().contains("z/os"); + isOs400 = (osName != null) && osName.toLowerCase().contains("os/400"); if (isHpUx) { // remove extra hp-ux suffix for parsing @@ -153,7 +155,7 @@ public boolean isJ9VM() { return isJ9; } - public boolean isHpUx(){ + public boolean isHpUx() { return isHpUx; } @@ -173,6 +175,10 @@ public boolean isZos() { return isZos; } + public boolean isOs400() { + return isOs400; + } + @Override public String toString() { return String.format("%s %s %s", javaVersion, javaVmName, javaVmVersion); diff --git a/apm-agent-common/src/main/java/co/elastic/apm/agent/common/util/ResourceExtractionUtil.java b/apm-agent-common/src/main/java/co/elastic/apm/agent/common/util/ResourceExtractionUtil.java index fcb4177ad3..be22567d85 100644 --- a/apm-agent-common/src/main/java/co/elastic/apm/agent/common/util/ResourceExtractionUtil.java +++ b/apm-agent-common/src/main/java/co/elastic/apm/agent/common/util/ResourceExtractionUtil.java @@ -101,9 +101,10 @@ public static synchronized Path extractResourceToDirectory(String resource, Stri } } } catch (FileAlreadyExistsException e) { - try (FileChannel channel = JvmRuntimeInfo.ofCurrentVM().isZos() ? - FileChannel.open(tempFile, READ) : - FileChannel.open(tempFile, READ, NOFOLLOW_LINKS)) { + JvmRuntimeInfo jvmRuntimeInfo = JvmRuntimeInfo.ofCurrentVM(); + try (FileChannel channel = (jvmRuntimeInfo.isZos() || jvmRuntimeInfo.isOs400()) ? + FileChannel.open(tempFile, READ) : + FileChannel.open(tempFile, READ, NOFOLLOW_LINKS)) { // wait until other JVM instances have fully written the file // multiple JVMs can read the file at the same time try (FileLock readLock = channel.lock(0, Long.MAX_VALUE, true)) {