commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1563014 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
Date Thu, 30 Jan 2014 23:28:27 GMT
Author: ggregory
Date: Thu Jan 30 23:28:26 2014
New Revision: 1563014

URL: http://svn.apache.org/r1563014
Log:
[LANG-961] org.apache.commons.lang3.reflect.FieldUtils.removeFinalModifier(Field) does not
clean up after itself. Only call setAccessible if neccessary and tell the caller about it
so it can undo the change if need be.

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java?rev=1563014&r1=1563013&r2=1563014&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/MemberUtils.java
Thu Jan 30 23:28:26 2014
@@ -49,20 +49,22 @@ abstract class MemberUtils {
      * sufficiently privileged code. Better workarounds would be gratefully
      * accepted.
      * @param o the AccessibleObject to set as accessible
+     * @return a boolean indicating whether the accessibility of the object was set to true.
      */
-    static void setAccessibleWorkaround(final AccessibleObject o) {
+    static boolean setAccessibleWorkaround(final AccessibleObject o) {
         if (o == null || o.isAccessible()) {
-            return;
+            return false;
         }
         final Member m = (Member) o;
-        if (Modifier.isPublic(m.getModifiers())
-                && isPackageAccess(m.getDeclaringClass().getModifiers())) {
+        if (!o.isAccessible() && Modifier.isPublic(m.getModifiers()) && isPackageAccess(m.getDeclaringClass().getModifiers()))
{
             try {
                 o.setAccessible(true);
+                return true;
             } catch (final SecurityException e) { // NOPMD
                 // ignore in favor of subsequent IllegalAccessException
             }
         }
+        return false;
     }
 
     /**



Mime
View raw message