8215493: String::indent inconsistency with blank lines
authorjlaskey
Wed, 09 Jan 2019 18:17:36 -0400
changeset 53245 05c5c27b5a54
parent 53231 ee1f64096d7c
child 53246 0740588d1f8a
8215493: String::indent inconsistency with blank lines Reviewed-by: rriggs, smarks
src/java.base/share/classes/java/lang/String.java
test/jdk/java/lang/String/Indent.java
--- a/src/java.base/share/classes/java/lang/String.java	Wed Jan 09 16:41:16 2019 -0400
+++ b/src/java.base/share/classes/java/lang/String.java	Wed Jan 09 18:17:36 2019 -0400
@@ -2813,8 +2813,7 @@
      * lines are then concatenated and returned.
      * <p>
      * If {@code n > 0} then {@code n} spaces (U+0020) are inserted at the
-     * beginning of each line. {@link String#isBlank() Blank lines} are
-     * unaffected.
+     * beginning of each line.
      * <p>
      * If {@code n < 0} then up to {@code n}
      * {@link Character#isWhitespace(int) white space characters} are removed
@@ -2849,7 +2848,7 @@
                                              : lines();
         if (n > 0) {
             final String spaces = " ".repeat(n);
-            stream = stream.map(s -> s.isBlank() ? s : spaces + s);
+            stream = stream.map(s -> spaces + s);
         } else if (n == Integer.MIN_VALUE) {
             stream = stream.map(s -> s.stripLeading());
         } else if (n < 0) {
--- a/test/jdk/java/lang/String/Indent.java	Wed Jan 09 16:41:16 2019 -0400
+++ b/test/jdk/java/lang/String/Indent.java	Wed Jan 09 18:17:36 2019 -0400
@@ -67,7 +67,7 @@
                         Stream<String> stream = input.lines();
                         if (adjust > 0) {
                             final String spaces = " ".repeat(adjust);
-                            stream = stream.map(s -> s.isBlank() ? s : spaces + s);
+                            stream = stream.map(s -> spaces + s);
                         } else if (adjust < 0) {
                             stream = stream.map(s -> s.substring(Math.min(-adjust, indexOfNonWhitespace(s))));
                         }