From 02a2738cd21038af7e437e67bb4aa1410b3ad43d Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 3 May 2017 13:15:54 -0400 Subject: [PATCH] Do not try to use cleaner if no unsafe Motivation: If unsafe is unavailable, we can not use the cleaner anyway. If we try to set it up, we get an annoying log message about unsafe being unavailable (when debug logging is enabled). We know this will fail, so we should not even bother and avoid the log message. Modifications: This commit adds a guard against setting up the cleaner if it is not going to be available because unsafe is unavailable. Result: We do not try to set up the cleaner if unsafe is unavailable, and we do not get an annoying log message. --- .../src/main/java/io/netty/util/internal/PlatformDependent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/io/netty/util/internal/PlatformDependent.java b/common/src/main/java/io/netty/util/internal/PlatformDependent.java index d27ac39169..fcc1c20f13 100644 --- a/common/src/main/java/io/netty/util/internal/PlatformDependent.java +++ b/common/src/main/java/io/netty/util/internal/PlatformDependent.java @@ -175,7 +175,7 @@ public final class PlatformDependent { MAYBE_SUPER_USER = maybeSuperUser0(); - if (!isAndroid()) { + if (!isAndroid() && hasUnsafe()) { // only direct to method if we are not running on android. // See https://github.com/netty/netty/issues/2604 if (javaVersion() >= 9) {