You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the system property JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR does not work and creates faulty documents with the value of the property instead of the value of the LineSeparator enum.
Calling System.setProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, "SYSTEM"); before anything else should make the system line separator the default line separator when serializing. Instead, the default line separator is initialized to the String value "SYSTEM".
Here is a test that currently fails with version 2.0.4 of JDom (Java 6 or Java 7):
package org.flexo.model;
import junit.framework.Assert;
import org.jdom2.JDOMConstants;
import org.jdom2.output.LineSeparator;
import org.junit.Test;
public class TestJDomLineSeparator {
@Test
public void testLineSeparatorFromSystemProperty() {
System.setProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, "SYSTEM");
Assert.assertEquals(System.getProperty("line.separator"), LineSeparator.DEFAULT.value());
}
}
It seems that calling final LineSeparator sep = Enum.valueOf(LineSeparator.class, prop); throws an IllegalArgumentException when called during the initialization of the enum. The exception is silently caught and the system property is immediately returned (this last part does not make sense).
The text was updated successfully, but these errors were encountered:
Oh, and the reason the exception is silently ignored is for those times when you want your separator to be 'jinglebells', or some value that is not the defined name for a constant.
COde was trying to be too clever about value duplication. As a result, the enumberator values were trying to reference each other before they were initialized.
Fix is to just do things simpler. Much simpler.
Using the system property
JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR
does not work and creates faulty documents with the value of the property instead of the value of theLineSeparator
enum.Calling
System.setProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, "SYSTEM");
before anything else should make the system line separator the default line separator when serializing. Instead, the default line separator is initialized to theString
value"SYSTEM"
.Here is a test that currently fails with version 2.0.4 of JDom (Java 6 or Java 7):
It seems that calling
final LineSeparator sep = Enum.valueOf(LineSeparator.class, prop);
throws anIllegalArgumentException
when called during the initialization of the enum. The exception is silently caught and the system property is immediately returned (this last part does not make sense).The text was updated successfully, but these errors were encountered: