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 2020/03/26 09:41:37 UTC

[groovy] 01/01: GROOVY-9481: Initialize meta class when checkInitalised returns false

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

sunlan pushed a commit to branch GROOVY-9481
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit ff29615de4d1f30c57b7374404ce1165acfe6be4
Author: Daniel Sun <su...@apache.org>
AuthorDate: Thu Mar 26 13:34:19 2020 +0800

    GROOVY-9481: Initialize meta class when checkInitalised returns false
---
 src/main/java/groovy/lang/MetaClassImpl.java | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 141deab..0d37ec2 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -1689,14 +1689,19 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
      * @throws IllegalStateException if the initialisation is incomplete yet
      */
     protected void checkInitalised() {
-        if (!isInitialized())
-            throw new IllegalStateException(
-                    "initialize must be called for meta " +
-                            "class of " + theClass +
-                            "(" + this.getClass() + ") " +
-                            "to complete initialisation process " +
-                            "before any invocation or field/property " +
-                            "access can be done");
+        if (!isInitialized()) {
+            try {
+                initialize();
+            } catch (Throwable t) {
+                throw new IllegalStateException(
+                        "initialize must be called for meta " +
+                                "class of " + theClass +
+                                "(" + this.getClass() + ") " +
+                                "to complete initialisation process " +
+                                "before any invocation or field/property " +
+                                "access can be done", t);
+            }
+        }
     }
 
     /**