You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/09/08 07:52:38 UTC

[groovy] branch danielsun/avoid-unnecessary-security-checks updated (a14a506 -> 6870410)

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

sunlan pushed a change to branch danielsun/avoid-unnecessary-security-checks
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard a14a506  GROOVY-10216: Avoid unnecessary security checks for each invocation
     new 6870410  GROOVY-10216: Avoid unnecessary security checks for each invocation

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a14a506)
            \
             N -- N -- N   refs/heads/danielsun/avoid-unnecessary-security-checks (6870410)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java | 1 +
 1 file changed, 1 insertion(+)

[groovy] 01/01: GROOVY-10216: Avoid unnecessary security checks for each invocation

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch danielsun/avoid-unnecessary-security-checks
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 687041045589d40d405c1fcf58572012cf4e4898
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Sep 8 15:49:43 2021 +0800

    GROOVY-10216: Avoid unnecessary security checks for each invocation
---
 .../java/org/codehaus/groovy/reflection/ReflectionUtils.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
index e85883b..e42a0c6 100644
--- a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
+++ b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
@@ -212,8 +212,16 @@ public class ReflectionUtils {
 
     // to be run in PrivilegedAction!
     public static Optional<AccessibleObject> makeAccessible(final AccessibleObject ao) {
+        if (ao.isAccessible()) {
+            try {
+                // Avoid unnecessary security checks for each invocation
+                ao.setAccessible(true);
+            } catch (Throwable ignore) {
+            }
+            return Optional.of(ao);
+        }
         try {
-            if (ao.isAccessible() || trySetAccessible(ao)) {
+            if (trySetAccessible(ao)) {
                 return Optional.of(ao);
             }
         } catch (Throwable ignore) {