Skip to content

Commit

Permalink
OS/400 avoids using NOFOLLOW_LINKS (#3905)
Browse files Browse the repository at this point in the history
* OS/400 avoids using NOFOLLOW_LINKS

* Add changelog entry for os-400-no-follow-links
  • Loading branch information
LikeTheSalad authored Dec 12, 2024
1 parent d3fa9fb commit 807b20b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit 807b20b

Please sign in to comment.