Skip to content

Commit

Permalink
Trivial refactoring: extract common variable
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Dec 27, 2024
1 parent 397bfb7 commit 145bf1d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/main/java/groovy/lang/Closure.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,14 @@ private Object getProperty(final Object receiver, final String property) {
try {
return InvokerHelper.getProperty(receiver, property);
} catch (GroovyRuntimeException e1) {
if (null != receiver && this != receiver && this instanceof GeneratedClosure
&& getThisType() != receiver.getClass() && getThisType().isInstance(receiver)) { // GROOVY-11128
try {
return ((GroovyObject) receiver).getMetaClass().getProperty(getThisType(), receiver, property, false, true);
} catch (GroovyRuntimeException e2) {
e1.addSuppressed(e2);
if (null != receiver && this != receiver && this instanceof GeneratedClosure) { // GROOVY-11128
final Class<?> thisType = getThisType();
if (thisType != receiver.getClass() && thisType.isInstance(receiver)) {
try {
return ((GroovyObject) receiver).getMetaClass().getProperty(thisType, receiver, property, false, true);
} catch (GroovyRuntimeException e2) {
e1.addSuppressed(e2);
}
}
}
throw e1;
Expand All @@ -395,13 +397,15 @@ private void setProperty(final Object receiver, final String property, final Obj
try {
InvokerHelper.setProperty(receiver, property, newValue);
} catch (GroovyRuntimeException e1) {
if (null != receiver && this != receiver && this instanceof GeneratedClosure
&& getThisType() != receiver.getClass() && getThisType().isInstance(receiver)) { // GROOVY-11128
try {
((GroovyObject) receiver).getMetaClass().setProperty(getThisType(), receiver, property, newValue, false, true);
return;
} catch (GroovyRuntimeException e2) {
e1.addSuppressed(e2);
if (null != receiver && this != receiver && this instanceof GeneratedClosure) { // GROOVY-11128
final Class<?> thisType = getThisType();
if (thisType != receiver.getClass() && thisType.isInstance(receiver)) {
try {
((GroovyObject) receiver).getMetaClass().setProperty(thisType, receiver, property, newValue, false, true);
return;
} catch (GroovyRuntimeException e2) {
e1.addSuppressed(e2);
}
}
}
throw e1;
Expand Down

0 comments on commit 145bf1d

Please sign in to comment.