This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 197a0b7  Remove use of JreCompat as it is not required with Java 11+
197a0b7 is described below

commit 197a0b7bcc8c00e63d29689158b287e77a46aa49
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Jul 28 13:57:19 2021 +0100

    Remove use of JreCompat as it is not required with Java 11+
---
 .../apache/tomcat/util/buf/ByteBufferUtils.java    | 42 +++++++---------------
 1 file changed, 13 insertions(+), 29 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java 
b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
index f69c7b3..de7d0e7 100644
--- a/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
+++ b/java/org/apache/tomcat/util/buf/ByteBufferUtils.java
@@ -23,7 +23,6 @@ import java.nio.ByteBuffer;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.compat.JreCompat;
 import org.apache.tomcat.util.res.StringManager;
 
 public class ByteBufferUtils {
@@ -42,34 +41,19 @@ public class ByteBufferUtils {
         Method cleanMethodLocal = null;
         Object unsafeLocal = null;
         Method invokeCleanerMethodLocal = null;
-        if (JreCompat.isJre9Available()) {
-            try {
-                Class<?> clazz = Class.forName("sun.misc.Unsafe");
-                Field theUnsafe = clazz.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                unsafeLocal = theUnsafe.get(null);
-                invokeCleanerMethodLocal = clazz.getMethod("invokeCleaner", 
ByteBuffer.class);
-                invokeCleanerMethodLocal.invoke(unsafeLocal, tempBuffer);
-            } catch (IllegalAccessException | IllegalArgumentException
-                    | InvocationTargetException | NoSuchMethodException | 
SecurityException
-                    | ClassNotFoundException | NoSuchFieldException e) {
-                log.warn(sm.getString("byteBufferUtils.cleaner"), e);
-                unsafeLocal = null;
-                invokeCleanerMethodLocal = null;
-            }
-        } else {
-            try {
-                cleanerMethodLocal = 
tempBuffer.getClass().getMethod("cleaner");
-                cleanerMethodLocal.setAccessible(true);
-                Object cleanerObject = cleanerMethodLocal.invoke(tempBuffer);
-                cleanMethodLocal = cleanerObject.getClass().getMethod("clean");
-                cleanMethodLocal.invoke(cleanerObject);
-            } catch (NoSuchMethodException | SecurityException | 
IllegalAccessException |
-                    IllegalArgumentException | InvocationTargetException e) {
-                log.warn(sm.getString("byteBufferUtils.cleaner"), e);
-                cleanerMethodLocal = null;
-                cleanMethodLocal = null;
-            }
+        try {
+            Class<?> clazz = Class.forName("sun.misc.Unsafe");
+            Field theUnsafe = clazz.getDeclaredField("theUnsafe");
+            theUnsafe.setAccessible(true);
+            unsafeLocal = theUnsafe.get(null);
+            invokeCleanerMethodLocal = clazz.getMethod("invokeCleaner", 
ByteBuffer.class);
+            invokeCleanerMethodLocal.invoke(unsafeLocal, tempBuffer);
+        } catch (IllegalAccessException | IllegalArgumentException
+                | InvocationTargetException | NoSuchMethodException | 
SecurityException
+                | ClassNotFoundException | NoSuchFieldException e) {
+            log.warn(sm.getString("byteBufferUtils.cleaner"), e);
+            unsafeLocal = null;
+            invokeCleanerMethodLocal = null;
         }
         cleanerMethod = cleanerMethodLocal;
         cleanMethod = cleanMethodLocal;

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to