Skip to content

Line separator System property fails #114

Description

@gpolet

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions