Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.8.0, 1.8.1
-
Fix Version/s: None
-
Component/s: groovy-jdk
-
Labels:None
-
Environment:windows 7 64 bit, jdk 1.6.0_25 (32bit)
-
Number of attachments :
Description
When writing a ConfigObject with a deep hierarchy, where some levels have no siblings, to file, some levels of the hierarchy get lost.
See the following code snipet
def config = new ConfigObject() config.db.hibernate.connection.url='jdbc:h2:file:C:/Temp/database;AUTO_SERVER=true' config.db.hibernate.connection.username='sa' config.db.hibernate.connection.password='' def file = new File('C:/Temp/config.groovy') file.withWriter { writer -> config.writeTo(writer) }
This produces a file like this:
connection {
url="jdbc:h2:file:C:/Temp/database;AUTO_SERVER=true"
username="sa"
password=""
}
What I would expect is:
db {
hibernate {
connection {
url="jdbc:h2:file:C:/Temp/database;AUTO_SERVER=true"
username="sa"
password=""
}
}
}
Activity
Dieter Rehbein
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Attachment | ConfigObject.groovy [ 59471 ] |
Dieter Rehbein
made changes -
| Attachment | Groovy4957Bug.groovy [ 59472 ] |
Dieter Rehbein
made changes -
| Attachment | ConfigObjectWriter.groovy [ 59473 ] |
Dieter Rehbein
made changes -
| Attachment | ConfigObject.diff [ 59483 ] |
Pascal Schumacher
made changes -
| Component/s | groovy-jdk [ 10750 ] |
Since I really needed this bug to be fixed, I've done it myself. I've completely rewritten the writeTo(Writer) method (IMHO it's much simpler now and easier to read) and added a new unit-test. All unit tests succeeded with this change (I made the changes based on groovy 1.8.6).
You might also use the attached ConfigObjectWriter, if you need a fix, before a new version of groovy is available.
Hope, it helps
best regards
Dieter