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/29 22:01:34 UTC

(commons-lang) 02/02: Don't check accessibility twice in MemberUtils.setAccessibleWorkaround(T)

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-lang.git

commit c67935e9b00a8d1f80a3eea44d2b9ac0620cb26b
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Fri Aug 29 18:01:26 2025 -0400

    Don't check accessibility twice in
    MemberUtils.setAccessibleWorkaround(T)
---
 src/changes/changes.xml                                         | 1 +
 src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5ec86830f..340f9906f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1783" type="fix" dev="ggregory" due-to="Arnout Engelen, Stanislav Fort, Gary Gregory">WordUtils.containsAllWords​() may throw PatternSyntaxException.</action>
     <action                   type="fix" dev="ggregory" due-to="Joe Ferner, Gary Gregory">MethodUtils cannot find or invoke vararg methods without providing vararg types or values #1427.</action>
     <action                   type="fix" dev="ggregory" due-to="Joe Ferner, Gary Gregory">MethodUtils cannot find or invoke vararg methods of interface types.</action>
+    <action                   type="fix" dev="ggregory" due-to="Gary Gregory">Don't check accessibility twice in MemberUtils.setAccessibleWorkaround(T).</action>
     <!-- FIX Javadoc -->
     <action                   type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] General improvements.</action>
     <action                   type="fix" dev="ggregory" due-to="Gary Gregory">[javadoc] Fix thrown exception documentation for org.apache.commons.lang3.reflect.MethodUtils.getMethodObject(Class&lt;?&gt;, String, Class&lt;?&gt;...).</action>
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
index 3a47050c1..219bec7d2 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
@@ -328,7 +328,7 @@ static <T extends AccessibleObject> T setAccessibleWorkaround(final T obj) {
             return obj;
         }
         final Member m = (Member) obj;
-        if (!obj.isAccessible() && isPublic(m) && isPackageAccess(m.getDeclaringClass().getModifiers())) {
+        if (isPublic(m) && isPackageAccess(m.getDeclaringClass().getModifiers())) {
             try {
                 obj.setAccessible(true);
                 return obj;