提交 2b93df07 编写于 作者: I igerasim

6854417: TESTBUG: java/util/regex/RegExTest.java fails intermittently

Reviewed-by: sherman
上级 98b9bc3e
/* /*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133 * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
* 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066 * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
* 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590 * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590
* 8027645 * 8027645 6854417
*/ */
import java.util.regex.*; import java.util.regex.*;
...@@ -3131,15 +3131,26 @@ public class RegExTest { ...@@ -3131,15 +3131,26 @@ public class RegExTest {
// Create a short pattern to search for // Create a short pattern to search for
int patternLength = generator.nextInt(7) + 4; int patternLength = generator.nextInt(7) + 4;
StringBuffer patternBuffer = new StringBuffer(patternLength); StringBuffer patternBuffer = new StringBuffer(patternLength);
for (int x=0; x<patternLength; x++) { String pattern;
int ch = baseCharacter + generator.nextInt(26); retry: for (;;) {
if (Character.isSupplementaryCodePoint(ch)) { for (int x=0; x<patternLength; x++) {
patternBuffer.append(Character.toChars(ch)); int ch = baseCharacter + generator.nextInt(26);
} else { if (Character.isSupplementaryCodePoint(ch)) {
patternBuffer.append((char)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;
} }
String pattern = patternBuffer.toString();
Pattern p = Pattern.compile(pattern); Pattern p = Pattern.compile(pattern);
// Create a buffer with random ASCII chars that does // Create a buffer with random ASCII chars that does
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册