Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 4089e8bb9 -> 5349e7e71


Minor refactoring

(cherry picked from commit 010624d)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5349e7e7
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5349e7e7
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5349e7e7

Branch: refs/heads/GROOVY_2_6_X
Commit: 5349e7e711d47415d9540a3806eecc79ef5f50fa
Parents: 4089e8b
Author: sunlan <[email protected]>
Authored: Sun Aug 27 00:22:58 2017 +0800
Committer: sunlan <[email protected]>
Committed: Sun Aug 27 00:31:13 2017 +0800

----------------------------------------------------------------------
 src/main/groovy/lang/GroovyObjectSupport.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5349e7e7/src/main/groovy/lang/GroovyObjectSupport.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/lang/GroovyObjectSupport.java 
b/src/main/groovy/lang/GroovyObjectSupport.java
index 2c4236c..cf7a77f 100644
--- a/src/main/groovy/lang/GroovyObjectSupport.java
+++ b/src/main/groovy/lang/GroovyObjectSupport.java
@@ -31,7 +31,7 @@ public abstract class GroovyObjectSupport implements 
GroovyObject {
     private transient MetaClass metaClass;
 
     public GroovyObjectSupport() {
-        this.metaClass = InvokerHelper.getMetaClass(this.getClass());
+        this.metaClass = getDefaultMetaClass();
     }
 
     public Object getProperty(String property) {
@@ -47,13 +47,17 @@ public abstract class GroovyObjectSupport implements 
GroovyObject {
     }
 
     public MetaClass getMetaClass() {
-        if (metaClass == null) {
-            metaClass = InvokerHelper.getMetaClass(getClass());
-        }
-        return metaClass;
+        return this.metaClass;
     }
 
     public void setMetaClass(MetaClass metaClass) {
-        this.metaClass = metaClass;
+        this.metaClass =
+                null == metaClass
+                    ? getDefaultMetaClass()
+                    : metaClass;
+    }
+
+    private MetaClass getDefaultMetaClass() {
+        return InvokerHelper.getMetaClass(this.getClass());
     }
 }

Reply via email to