Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS/400 avoids using NOFOLLOW_LINKS #3905

Merged
merged 2 commits into from
Dec 12, 2024
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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -153,7 +155,7 @@ public boolean isJ9VM() {
return isJ9;
}

public boolean isHpUx(){
public boolean isHpUx() {
return isHpUx;
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading