This appears to be a Java problem, not a Groovy problem,  and possibly an 
OpenJDK issue.
I’ve only been able to test this further on my Mac laptop as I cannot install 
different versions of Java.
Java 8 works as expected
I’ve tried Java 10, 11, 17, 18 and 19 and all appear to exhibit this behavior

From: Nelson, Erick <erick.nel...@hdsupply.com>
Date: Tuesday, March 21, 2023 at 10:25 AM
To: users@groovy.apache.org <users@groovy.apache.org>
Subject: Extra linefeeds with groovy.xml.XmlUtil.serialize
I get extra line feeds on my mac when running identical code. Does anybody know 
why this would be?

On Linux… (expected output)

[tauser02@cfmips01ld0s work]$ groovy -v
Groovy Version: 4.0.10 JVM: 1.8.0_362 Vendor: Red Hat, Inc. OS: Linux
[tauser02@cfmips01ld0s work]$ cat test.groovy
String xml = $/<?xml version="1.0" encoding="UTF-8"?><root><elem1 
attr1="value1" attr2="value2"/><elem2 attr1="value4" attr2="value4"/></root>/$
def doc = new groovy.xml.XmlParser().parseText(xml)
println groovy.xml.XmlUtil.serialize(doc)
[tauser02@cfmips01ld0s work]$ groovy test.groovy
<?xml version="1.0" encoding="UTF-8"?><root>
<elem1 attr1="value1" attr2="value2"/>
<elem2 attr1="value4" attr2="value4"/>
</root>



On my MAC…(note extra line feeds output)


en032339@C02CJMZ8MD6M ~ % groovy -v

Groovy Version: 4.0.10 JVM: 18.0.2.1 Vendor: Eclipse Adoptium OS: Mac OS X

en032339@C02CJMZ8MD6M ~ % cat test.groovy

String xml = $/<?xml version="1.0" encoding="UTF-8"?><root><elem1 
attr1="value1" attr2="value2"/><elem2 attr1="value4" attr2="value4"/></root>/$

def doc = new groovy.xml.XmlParser().parseText(xml)

println groovy.xml.XmlUtil.serialize(doc)

en032339@C02CJMZ8MD6M ~ % groovy test.groovy

<?xml version="1.0" encoding="UTF-8"?><root>



  <elem1 attr1="value1" attr2="value2"/>



  <elem2 attr1="value4" attr2="value4"/>



</root>

Reply via email to