You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/08/05 11:26:47 UTC

(commons-beanutils) branch master updated: Drop code that will never run since we are on Java 8 or greater

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git


The following commit(s) were added to refs/heads/master by this push:
     new 60e3e0cc Drop code that will never run since we are on Java 8 or greater
60e3e0cc is described below

commit 60e3e0ccd35193fd8505885030456fec13a51334
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Tue Aug 5 07:26:42 2025 -0400

    Drop code that will never run since we are on Java 8 or greater
---
 .../org/apache/commons/beanutils2/MethodUtils.java | 34 ++--------------------
 1 file changed, 2 insertions(+), 32 deletions(-)

diff --git a/src/main/java/org/apache/commons/beanutils2/MethodUtils.java b/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
index 264ed6a5..e6ccd9f7 100644
--- a/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
+++ b/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
@@ -28,7 +28,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.WeakHashMap;
 
-import org.apache.commons.lang3.SystemProperties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -108,16 +107,6 @@ public final class MethodUtils {
 
     private static final Log LOG = LogFactory.getLog(MethodUtils.class);
 
-    /**
-     * Only log warning about accessibility work around once.
-     * <p>
-     * Note that this is broken when this class is deployed via a shared classloader in a container, as the warning message will be emitted only once, not once
-     * per webapp. However making the warning appear once per webapp means having a map keyed by context classloader which introduces nasty memory-leak
-     * problems. As this warning is really optional we can ignore this problem; only one of the webapps will get the warning in its logs but that should be good
-     * enough.
-     */
-    private static boolean loggedAccessibleWarning;
-
     /**
      * Indicates whether methods should be cached for improved performance.
      * <p>
@@ -1121,28 +1110,9 @@ public final class MethodUtils {
             if (!method.isAccessible()) {
                 method.setAccessible(true);
             }
-
-        } catch (final SecurityException se) {
+        } catch (final SecurityException e) {
             // log but continue just in case the method.invoke works anyway
-            if (!loggedAccessibleWarning) {
-                boolean vulnerableJVM = false;
-                try {
-                    final String specVersion = SystemProperties.getJavaSpecificationVersion();
-                    if (specVersion.charAt(0) == '1'
-                            && (specVersion.charAt(2) == '0' || specVersion.charAt(2) == '1' || specVersion.charAt(2) == '2' || specVersion.charAt(2) == '3')) {
-
-                        vulnerableJVM = true;
-                    }
-                } catch (final SecurityException e) {
-                    // don't know - so display warning
-                    vulnerableJVM = true;
-                }
-                if (vulnerableJVM) {
-                    LOG.warn("Current Security Manager restricts use of workarounds for reflection bugs in pre-1.4 JVMs.");
-                }
-                loggedAccessibleWarning = true;
-            }
-            LOG.debug("Cannot setAccessible on method. Therefore cannot use jvm access bug workaround.", se);
+            LOG.debug("Cannot setAccessible on method. Therefore cannot use jvm access bug workaround.", e);
         }
     }