Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Use subheadings with the "=====" level for adding notes for unreleased changes:
* Restore compatibility with Java 7 - {pull}3657[#3657]
* Avoid `ClassCastException` and issue warning when trying to use otel span links - {pull}3672[#3672]
* Avoid `NullPointerException` with runtime attach API and invalid map entries - {pull}3712[#3712]
* Skips using NOFOLLOW_LINKS file open option when running on z/OS as it's unsupported there - {pull}3722[#3722]

[float]
===== Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
public class JvmRuntimeInfo {

private static final JvmRuntimeInfo CURRENT_VM = new JvmRuntimeInfo(System.getProperty("java.version"),
System.getProperty("java.vm.name"), System.getProperty("java.vendor"), System.getProperty("java.vm.version"));
System.getProperty("java.vm.name"), System.getProperty("java.vendor"), System.getProperty("java.vm.version"),
System.getProperty("os.name"));

private final String javaVersion;
private final String javaVmName;
Expand All @@ -37,6 +38,7 @@ public class JvmRuntimeInfo {
private final boolean isJ9;
private final boolean isHpUx;
private final boolean isCoretto;
private final boolean isZos;

public static JvmRuntimeInfo ofCurrentVM() {
return CURRENT_VM;
Expand All @@ -52,6 +54,10 @@ public static JvmRuntimeInfo ofCurrentVM() {
* @param vmVersion jvm version, from {@code System.getProperty("java.vm.version")}
*/
public JvmRuntimeInfo(String version, String vmName, String vendorName, @Nullable String vmVersion) {
this(version, vmName, vendorName, vmVersion, null);
}

private JvmRuntimeInfo(String version, String vmName, String vendorName, @Nullable String vmVersion, @Nullable String osName) {
javaVersion = version;
javaVmName = vmName;
javaVmVersion = vmVersion;
Expand All @@ -61,6 +67,7 @@ public JvmRuntimeInfo(String version, String vmName, String vendorName, @Nullabl
isJ9 = vmName.contains("J9");
isHpUx = version.endsWith("-hp-ux");
isCoretto = vendorName != null && vendorName.contains("Amazon");
isZos = (osName != null) && osName.toLowerCase().contains("z/os");

if (isHpUx) {
// remove extra hp-ux suffix for parsing
Expand Down Expand Up @@ -162,6 +169,10 @@ public boolean isCoretto() {
return isCoretto;
}

public boolean isZos() {
return isZos;
}

@Override
public String toString() {
return String.format("%s %s %s", javaVersion, javaVmName, javaVmVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package co.elastic.apm.agent.common.util;

import co.elastic.apm.agent.common.JvmRuntimeInfo;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
Expand Down Expand Up @@ -99,7 +101,9 @@ public static synchronized Path extractResourceToDirectory(String resource, Stri
}
}
} catch (FileAlreadyExistsException e) {
try (FileChannel channel = FileChannel.open(tempFile, READ, NOFOLLOW_LINKS)) {
try (FileChannel channel = JvmRuntimeInfo.ofCurrentVM().isZos() ?
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)) {
Expand Down