08 Dec 2008, 20:50

Doug Kartio (1 post)

Running the code examples in the XML chapter seems to show problems with the code and newer versions of Groovy.

My java version is 1.6.0-07 and my groovy version is 1.5.7

The example code:

document = groovy.xml.DOMBuilder.parse(new FileReader('languages.xml'))
rootElement = document.documentElement
	println "Languages and authors"
	languages = rootElement.language	
	languages.each {language ->
	  println "${language.'@name'} authored by ${language.author[0].text()}"
	def languagesByAuthor = {authorName ->
	  languages.findAll {it.author[0].text() ==authorName}.collect{it.'@name'}.join(', ')}	
	println "Languages by Wirth: " + languagesByAuthor('Wirth')	

results in a “java.lang.StackOverflowError” exception

If I change the “println” to “System.out.println” it works fine. Is this a version problem and if so, what other examples/commands are not going to work correctly.


09 Dec 2008, 00:31

Venkat Subramaniam (86 posts)

Doug, good catch. Looks like a bug to me. I’ll file a JIRA. Thanks.

09 Dec 2008, 00:46

Venkat Subramaniam (86 posts)

It’s tricky. Not failing from unit test, but fails from real code!

11 Dec 2008, 14:37

Venkat Subramaniam (86 posts)

Please see the following for details about fix: http://jira.codehaus.org/browse/GROOVY-3189 http://jira.codehaus.org/browse/GROOVY-3109

  You must be logged in to comment