author | naoto |
Wed, 12 Oct 2011 12:12:25 -0700 | |
changeset 10710 | b18db2d63e3b |
parent 6835 | 859aa05172b6 |
child 13583 | dc0017b1a452 |
permissions | -rw-r--r-- |
6835
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
1 |
/* |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
4 |
* |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
8 |
* |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
13 |
* accompanied this code). |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
14 |
* |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
18 |
* |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
21 |
* questions. |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
22 |
*/ |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
23 |
|
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
24 |
/* |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
25 |
* @test |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
26 |
* @bug 6989440 |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
27 |
* @summary Verify ConcurrentModificationException is not thrown with multiple |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
28 |
* thread accesses. |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
29 |
* @compile -XDignore.symbol.file=true Bug6989440.java |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
30 |
* @run main Bug6989440 |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
31 |
*/ |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
32 |
import java.text.spi.DateFormatProvider; |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
33 |
import java.util.spi.LocaleNameProvider; |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
34 |
import java.util.spi.LocaleServiceProvider; |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
35 |
import java.util.spi.TimeZoneNameProvider; |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
36 |
|
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
37 |
import sun.util.LocaleServiceProviderPool; |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
38 |
|
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
39 |
public class Bug6989440 { |
10710
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
40 |
static volatile boolean failed; // false |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
41 |
static final int THREADS = 50; |
6835
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
42 |
|
10710
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
43 |
public static void main(String[] args) throws Exception { |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
44 |
Thread[] threads = new Thread[THREADS]; |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
45 |
for (int i=0; i<threads.length; i++) |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
46 |
threads[i] = new TestThread(); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
47 |
for (int i=0; i<threads.length; i++) |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
48 |
threads[i].start(); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
49 |
for (int i=0; i<threads.length; i++) |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
50 |
threads[i].join(); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
51 |
|
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
52 |
if (failed) |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
53 |
throw new RuntimeException("Failed: check output"); |
6835
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
54 |
} |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
55 |
|
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
56 |
static class TestThread extends Thread { |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
57 |
private Class<? extends LocaleServiceProvider> cls; |
10710
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
58 |
private static int count; |
6835
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
59 |
|
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
60 |
public TestThread(Class<? extends LocaleServiceProvider> providerClass) { |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
61 |
cls = providerClass; |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
62 |
} |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
63 |
|
10710
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
64 |
public TestThread() { |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
65 |
int which = count++ % 3; |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
66 |
switch (which) { |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
67 |
case 0 : cls = LocaleNameProvider.class; break; |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
68 |
case 1 : cls = TimeZoneNameProvider.class; break; |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
69 |
case 2 : cls = DateFormatProvider.class; break; |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
70 |
default : throw new AssertionError("Should not reach here"); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
71 |
} |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
72 |
} |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
73 |
|
6835
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
74 |
public void run() { |
10710
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
75 |
try { |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
76 |
LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
77 |
pool.getAvailableLocales(); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
78 |
} catch (Exception e) { |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
79 |
System.out.println(e); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
80 |
e.printStackTrace(); |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
81 |
failed = true; |
b18db2d63e3b
7027061: Testcase failure: java/util/Locale/Bug6989440.java - java.util.ConcurrentModificationException
naoto
parents:
6835
diff
changeset
|
82 |
} |
6835
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
83 |
} |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
84 |
} |
859aa05172b6
6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException
naoto
parents:
diff
changeset
|
85 |
} |