Use System#lineSeparator instead of System.getProperty("line.separator") (closes #1145)
diff --git a/src/main/java/org/codehaus/groovy/tools/Utilities.java b/src/main/java/org/codehaus/groovy/tools/Utilities.java
index 522b5d3..41a7b00 100644
--- a/src/main/java/org/codehaus/groovy/tools/Utilities.java
+++ b/src/main/java/org/codehaus/groovy/tools/Utilities.java
@@ -72,6 +72,6 @@
return true;
}
- private static String eol = System.getProperty( "line.separator", "\n" );
+ private static String eol = System.lineSeparator();
}
diff --git a/src/tck/src/org/codehaus/groovy/tck/ClassicGroovyTestGeneratorHelper.java b/src/tck/src/org/codehaus/groovy/tck/ClassicGroovyTestGeneratorHelper.java
index 373d5ea..a0854c3 100644
--- a/src/tck/src/org/codehaus/groovy/tck/ClassicGroovyTestGeneratorHelper.java
+++ b/src/tck/src/org/codehaus/groovy/tck/ClassicGroovyTestGeneratorHelper.java
@@ -105,5 +105,5 @@
return decorateWithLineNumbersAndErrorMessage(theSrcText,null);
}
- protected String lineSep = System.getProperty("line.separator");
+ protected String lineSep = System.lineSeparator();
}
diff --git a/src/tck/src/org/codehaus/groovy/tck/TestGenerator.groovy b/src/tck/src/org/codehaus/groovy/tck/TestGenerator.groovy
index aa93eeb..85d32db 100644
--- a/src/tck/src/org/codehaus/groovy/tck/TestGenerator.groovy
+++ b/src/tck/src/org/codehaus/groovy/tck/TestGenerator.groovy
@@ -118,7 +118,7 @@
result.println(" }")
result.println(" }")
}
- result.println(' protected String lineSep = System.getProperty("line.separator");')
+ result.println(' protected String lineSep = System.lineSeparator();')
result.println(' protected TestGeneratorHelper helper = new ClassicGroovyTestGeneratorHelper();')
result.println("}")
diff --git a/src/test/groovy/PrintTest.groovy b/src/test/groovy/PrintTest.groovy
index 53c3656..f567f3f 100644
--- a/src/test/groovy/PrintTest.groovy
+++ b/src/test/groovy/PrintTest.groovy
@@ -96,7 +96,7 @@
}
}
-def NEWLINE = System.getProperty("line.separator")
+def NEWLINE = System.lineSeparator()
void doTest(def param) {
StringWriter sw1 = new StringWriter()
diff --git a/src/test/groovy/inspect/InspectorTest.java b/src/test/groovy/inspect/InspectorTest.java
index 51a3bc8..6284da9 100644
--- a/src/test/groovy/inspect/InspectorTest.java
+++ b/src/test/groovy/inspect/InspectorTest.java
@@ -213,7 +213,7 @@
public void testPrint() {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(bytes);
- String ls = System.getProperty("line.separator");
+ String ls = System.lineSeparator();
String[] first = {"a", "b"};
String[] second = {"x", "y"};
Object[] memberInfo = {first, second};
diff --git a/src/test/groovy/io/PlatformLineWriterTest.java b/src/test/groovy/io/PlatformLineWriterTest.java
index e915e42..395fc5b 100644
--- a/src/test/groovy/io/PlatformLineWriterTest.java
+++ b/src/test/groovy/io/PlatformLineWriterTest.java
@@ -29,7 +29,7 @@
public class PlatformLineWriterTest extends TestCase {
public void testPlatformLineWriter() throws IOException, ClassNotFoundException {
- String LS = System.getProperty("line.separator");
+ String LS = System.lineSeparator();
Binding binding = new Binding();
binding.setVariable("first", "Tom");
binding.setVariable("last", "Adams");
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
index 7c0cd4e..891fd2d 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
@@ -1226,7 +1226,7 @@
scriptRunning = true
interruptAction.enabled = true
stackOverFlowError = false // reset this flag before running a script
- def endLine = System.getProperty('line.separator')
+ def endLine = System.lineSeparator()
def record = new HistoryRecord(allText: inputArea.getText().replace(endLine, '\n'),
selectionStart: textSelectionStart, selectionEnd: textSelectionEnd)
addToHistory(record)
@@ -1302,7 +1302,7 @@
return
}
stackOverFlowError = false // reset this flag before running a script
- def endLine = System.getProperty('line.separator')
+ def endLine = System.lineSeparator()
def record = new HistoryRecord(allText: inputArea.getText().replace(endLine, '\n'),
selectionStart: textSelectionStart, selectionEnd: textSelectionEnd)
@@ -1357,7 +1357,7 @@
}
private void setInputTextFromHistory(newIndex) {
- def endLine = System.getProperty('line.separator')
+ def endLine = System.lineSeparator()
if (historyIndex >= history.size()) {
pendingRecord = new HistoryRecord(allText: inputArea.getText().replace(endLine, '\n'),
selectionStart: textSelectionStart, selectionEnd: textSelectionEnd)
diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/CommandSupport.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/CommandSupport.groovy
index bdab2f1..09f4b78 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/CommandSupport.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/CommandSupport.groovy
@@ -33,7 +33,7 @@
abstract class CommandSupport
implements Command
{
- protected static final String NEWLINE = System.properties['line.separator']
+ protected static final String NEWLINE = System.lineSeparator()
/** Instance logger for the command, initialized late to include the command name. */
protected final Logger log
diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Parser.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Parser.groovy
index 96f4c25..857ef84 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Parser.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Parser.groovy
@@ -34,7 +34,7 @@
* Provides a facade over the parser to recognize valid Groovy syntax.
*/
class Parser {
- static final String NEWLINE = System.getProperty('line.separator')
+ static final String NEWLINE = System.lineSeparator()
private static final Logger log = Logger.create(Parser)
diff --git a/subprojects/groovy-templates/src/main/groovy/groovy/text/markup/TemplateConfiguration.java b/subprojects/groovy-templates/src/main/groovy/groovy/text/markup/TemplateConfiguration.java
index 282bdbe..e5ff8dc 100644
--- a/subprojects/groovy-templates/src/main/groovy/groovy/text/markup/TemplateConfiguration.java
+++ b/subprojects/groovy-templates/src/main/groovy/groovy/text/markup/TemplateConfiguration.java
@@ -28,7 +28,7 @@
private String declarationEncoding;
private boolean expandEmptyElements;
private boolean useDoubleQuotes;
- private String newLineString = System.getProperty("line.separator");
+ private String newLineString = System.lineSeparator();
private boolean autoEscape = false;
private boolean autoIndent = false;
private String autoIndentString = DelegatingIndentWriter.SPACES;
diff --git a/subprojects/groovy-templates/src/test/java/groovy/text/XmlTemplateEngineTest.java b/subprojects/groovy-templates/src/test/java/groovy/text/XmlTemplateEngineTest.java
index 159cc0e..39eb607 100644
--- a/subprojects/groovy-templates/src/test/java/groovy/text/XmlTemplateEngineTest.java
+++ b/subprojects/groovy-templates/src/test/java/groovy/text/XmlTemplateEngineTest.java
@@ -39,7 +39,7 @@
String xmlResult = "<xml>\n"
+ " Stein\n"
+ xmlTemplateEngine.getIndentation() + "Stein\n"
- + "Stein" + System.getProperty("line.separator")
+ + "Stein" + System.lineSeparator()
+ "</xml>\n";
Template template = xmlTemplateEngine.createTemplate(xmlScript);
assertEquals(xmlResult, template.make(binding).toString());
@@ -59,7 +59,7 @@
String xmlResult = "<xml>\n"
+ " Stein Stein\n"
+ xmlTemplateEngine.getIndentation() + "Stein Stein\n"
- + "Stein" + System.getProperty("line.separator")
+ + "Stein" + System.lineSeparator()
+ "</xml>\n";
Template template = xmlTemplateEngine.createTemplate(xmlScript);
assertEquals(xmlResult, template.make(binding).toString());
@@ -80,7 +80,7 @@
+ " Stein Stein\n"
+ xmlTemplateEngine.getIndentation() + "Stein Stein\n"
+ xmlTemplateEngine.getIndentation() + "<nonamespace>\n"
- + "Stein" + System.getProperty("line.separator")
+ + "Stein" + System.lineSeparator()
+ xmlTemplateEngine.getIndentation() + "</nonamespace>\n"
+ "</foo:bar>\n";
Template template = xmlTemplateEngine.createTemplate(xmlScript);