Repository: groovy
Updated Branches:
  refs/heads/master 05f76a0e0 -> 010624d92


Minor refactoring


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

Branch: refs/heads/master
Commit: 010624d9296e89f2fe241e03a6bfc344426bb726
Parents: 05f76a0
Author: sunlan <[email protected]>
Authored: Sun Aug 27 00:22:58 2017 +0800
Committer: sunlan <[email protected]>
Committed: Sun Aug 27 00:22:58 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/010624d9/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