Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.5
-
None
-
None
-
Issue consistently appears on Windows Vista, XP SP2 on IBM JDK 5 and Mac OS X 10.4.11 and 10.5.1 on Sun JDK 1.5.
Description
The issue appears when a Groovy class overrides the toString() method and the method makes a call that routes a call through its meta class. If the log level is set to a level where MetaClassHelper logs the method call, toString() on the Groovy class is called for logging purposes, thus beginning an infinite loop and subsequent stack overflow.
This happened simply by specifying ".level=ALL" in my logging properties. Scoping it to just the root package of my application avoided this issue.
For instance, my toString() method creates a StringBuffer and appends various information to build up a String to return. In the attached test case, "this.getClass().getName()" initiates an infinite loop. The infinite loop is caused by the following normalizedValue method in MetaClassHelper because it is initiated by a call in toString() and in turn calls toString() calls the same toString() method.