< prev index next >

test/java/util/regex/RegExTest.java

Print this page
rev 12323 : [mq]: 6854417-RegExTest-java-fails-intermittently

*** 1,7 **** /* ! * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 30,44 **** * 4872664 4803179 4892980 4900747 4945394 4938995 4979006 4994840 4997476 * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940 * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133 * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066 * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590 ! * 8027645 8035076 8039124 8035975 8074678 * @library /lib/testlibrary * @build jdk.testlibrary.* * @run main RegExTest ! * @key intermittent randomness */ import java.util.function.Function; import java.util.regex.*; import java.util.Random; --- 30,44 ---- * 4872664 4803179 4892980 4900747 4945394 4938995 4979006 4994840 4997476 * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940 * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133 * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066 * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590 ! * 8027645 8035076 8039124 8035975 8074678 6854417 * @library /lib/testlibrary * @build jdk.testlibrary.* * @run main RegExTest ! * @key randomness */ import java.util.function.Function; import java.util.regex.*; import java.util.Random;
*** 3552,3570 **** for (int i=0; i<100; i++) { // Create a short pattern to search for int patternLength = generator.nextInt(7) + 4; StringBuffer patternBuffer = new StringBuffer(patternLength); for (int x=0; x<patternLength; x++) { int ch = baseCharacter + generator.nextInt(26); if (Character.isSupplementaryCodePoint(ch)) { patternBuffer.append(Character.toChars(ch)); } else { patternBuffer.append((char)ch); } } ! String pattern = patternBuffer.toString(); Pattern p = Pattern.compile(pattern); // Create a buffer with random ASCII chars that does // not match the sample String toSearch = null; --- 3552,3581 ---- for (int i=0; i<100; i++) { // Create a short pattern to search for int patternLength = generator.nextInt(7) + 4; StringBuffer patternBuffer = new StringBuffer(patternLength); + String pattern; + retry: for (;;) { for (int x=0; x<patternLength; x++) { int ch = baseCharacter + generator.nextInt(26); if (Character.isSupplementaryCodePoint(ch)) { patternBuffer.append(Character.toChars(ch)); } else { patternBuffer.append((char)ch); } } ! pattern = patternBuffer.toString(); ! ! // Avoid patterns that start and end with the same substring ! // See JDK-6854417 ! for (int x=1; x <patternLength; x++) { ! if (pattern.startsWith(pattern.substring(x))) ! continue retry; ! } ! break; ! } Pattern p = Pattern.compile(pattern); // Create a buffer with random ASCII chars that does // not match the sample String toSearch = null;
< prev index next >