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:18:27 UTC

[groovy] branch danielsun/avoid-unnecessary-security-checks updated (d7d8fd5 -> 9b383ac)

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 d7d8fd5  Avoid unnecessary security checks for each invocation
     new 9b383ac  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   (d7d8fd5)
            \
             N -- N -- N   refs/heads/danielsun/avoid-unnecessary-security-checks (9b383ac)

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:
 .../java/org/codehaus/groovy/reflection/CachedConstructor.java     | 7 ++++++-
 src/main/java/org/codehaus/groovy/reflection/CachedField.java      | 7 ++++++-
 src/main/java/org/codehaus/groovy/reflection/CachedMethod.java     | 7 ++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)

[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 9b383ac8b3a9e78c61c7c7d2f9b5d36c01b580c3
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Sep 8 13:48:54 2021 +0800

    GROOVY-10216: Avoid unnecessary security checks for each invocation
---
 src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java | 6 ++++++
 src/main/java/org/codehaus/groovy/reflection/CachedField.java       | 6 ++++++
 src/main/java/org/codehaus/groovy/reflection/CachedMethod.java      | 6 ++++++
 3 files changed, 18 insertions(+)

diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java b/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java
index 1546bd4..8b584f1 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedConstructor.java
@@ -125,6 +125,12 @@ public class CachedConstructor extends ParameterTypes {
     private boolean makeAccessibleDone = false;
     private void makeAccessibleIfNecessary() {
         if (!makeAccessibleDone) {
+            if (cachedConstructor.isAccessible()) {
+                try {
+                    cachedConstructor.setAccessible(true);
+                } catch (Throwable ignored) {
+                }
+            }
             makeAccessibleInPrivilegedAction(cachedConstructor);
             makeAccessibleDone = true;
         }
diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedField.java b/src/main/java/org/codehaus/groovy/reflection/CachedField.java
index 6c666aa..6e7b64c 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedField.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedField.java
@@ -95,6 +95,12 @@ public class CachedField extends MetaProperty {
     private transient boolean madeAccessible;
     private void makeAccessibleIfNecessary() {
         if (!madeAccessible) {
+            if (field.isAccessible()) {
+                try {
+                    field.setAccessible(true);
+                } catch (Throwable ignored) {
+                }
+            }
             makeAccessibleInPrivilegedAction(field);
             madeAccessible = true;
         }
diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java b/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
index 838db6a..6eb68d8 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java
@@ -394,6 +394,12 @@ public class CachedMethod extends MetaMethod implements Comparable {
     private boolean makeAccessibleDone = false;
     private void makeAccessibleIfNecessary() {
         if (!makeAccessibleDone) {
+            if (cachedMethod.isAccessible()) {
+                try {
+                    cachedMethod.setAccessible(true);
+                } catch (Throwable ignored) {
+                }
+            }
             makeAccessibleInPrivilegedAction(cachedMethod);
             makeAccessibleDone = true;
         }