8159545: closed/java/io/Console/TestConsole.java failed with exit code 1
authorsherman
Wed, 22 Jun 2016 11:31:07 -0700
changeset 39141 e5d52546ba3a
parent 39140 86f21a96d0ab
child 39142 bf48a9f13cf2
8159545: closed/java/io/Console/TestConsole.java failed with exit code 1 Reviewed-by: rriggs
jdk/src/java.base/share/classes/java/util/Scanner.java
jdk/test/java/util/Scanner/ScanTest.java
--- a/jdk/src/java.base/share/classes/java/util/Scanner.java	Wed Jun 22 09:33:16 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Scanner.java	Wed Jun 22 11:31:07 2016 -0700
@@ -925,7 +925,6 @@
             needInput = true;
             return null;
         }
-
         // Must look for next delims. Simply attempting to match the
         // pattern at this point may find a match but it might not be
         // the first longest match because of missing input, or it might
@@ -941,16 +940,13 @@
             foundNextDelim = matcher.find();
         }
         if (foundNextDelim) {
-            // In two rare cases that more input might cause the match to be
-            // lost or change.
-            // (1) if requireEnd() is true, more input might cause the match
-            // to be lost, we must wait for more input.
-            // (2) while hitting the end is okay IF the match does not
-            // go away AND the beginning of the next delims does not change
-            // (we don't care if they potentially extend further). But it's
-            // possible that more input could cause the beginning of the
-            // delims change, so have to wait for more input as well.
-            if ((matcher.requireEnd() || matcher.hitEnd()) && !sourceClosed) {
+            // In the rare case that more input could cause the match
+            // to be lost and there is more input coming we must wait
+            // for more input. Note that hitting the end is okay as long
+            // as the match cannot go away. It is the beginning of the
+            // next delims we want to be sure about, we don't care if
+            // they potentially extend further.
+            if (matcher.requireEnd() && !sourceClosed) {
                 needInput = true;
                 return null;
             }
--- a/jdk/test/java/util/Scanner/ScanTest.java	Wed Jun 22 09:33:16 2016 -0700
+++ b/jdk/test/java/util/Scanner/ScanTest.java	Wed Jun 22 11:31:07 2016 -0700
@@ -24,7 +24,7 @@
 /**
  * @test
  * @bug 4313885 4926319 4927634 5032610 5032622 5049968 5059533 6223711 6277261 6269946 6288823
- *      8072722 8072582 8139414
+ *      8072722 8139414
  * @summary Basic tests of java.util.Scanner methods
  * @key randomness
  * @modules jdk.localedata
@@ -512,27 +512,9 @@
     }
 
     public static void boundaryDelimTest() throws Exception {
-        // 8072582
-        StringBuilder sb = new StringBuilder();
-        append(sb, 'a', 228); sb.append(",");
-        append(sb, 'b', 293); sb.append("#,#");
-        append(sb, 'c', 308); sb.append(",");
-        append(sb, 'd', 188); sb.append("#,#");
-        append(sb, 'e', 2);
-        try (Scanner scanner = new Scanner(sb.toString())) {
-            scanner.useDelimiter("(#,#)|(,)");
-            while(scanner.hasNext()){
-                String next = scanner.next();
-                if(next.contains("#")){
-                    System.out.printf("[%s]%n", next);
-                    failCount++;
-                }
-            }
-        }
-
         // 8139414
         int i = 1019;
-        sb = new StringBuilder();
+        StringBuilder sb = new StringBuilder();
         sb.append("--;");
         for (int j = 0; j < 1019; ++j) {
             sb.append(j%10);