2869N/A/*
2869N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2869N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2869N/A *
2869N/A * This code is free software; you can redistribute it and/or modify it
2869N/A * under the terms of the GNU General Public License version 2 only, as
2869N/A * published by the Free Software Foundation.
2869N/A *
2869N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2869N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2869N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2869N/A * version 2 for more details (a copy is included in the LICENSE file that
2869N/A * accompanied this code).
2869N/A *
2869N/A * You should have received a copy of the GNU General Public License version
2869N/A * 2 along with this work; if not, write to the Free Software Foundation,
2869N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2869N/A *
2869N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2869N/A * or visit www.oracle.com if you need additional information or have any
2869N/A * questions.
2869N/A */
2869N/A
2869N/A/*
2869N/A * @test
2869N/A * @bug 6989440
2869N/A * @summary Verify ConcurrentModificationException is not thrown with multiple
2869N/A * thread accesses.
2869N/A * @compile -XDignore.symbol.file=true Bug6989440.java
2869N/A * @run main Bug6989440
2869N/A */
2869N/Aimport java.text.spi.DateFormatProvider;
2869N/Aimport java.util.spi.LocaleNameProvider;
2869N/Aimport java.util.spi.LocaleServiceProvider;
2869N/Aimport java.util.spi.TimeZoneNameProvider;
2869N/A
2869N/Aimport sun.util.LocaleServiceProviderPool;
2869N/A
2869N/Apublic class Bug6989440 {
4564N/A static volatile boolean failed; // false
4564N/A static final int THREADS = 50;
2869N/A
4564N/A public static void main(String[] args) throws Exception {
4564N/A Thread[] threads = new Thread[THREADS];
4564N/A for (int i=0; i<threads.length; i++)
4564N/A threads[i] = new TestThread();
4564N/A for (int i=0; i<threads.length; i++)
4564N/A threads[i].start();
4564N/A for (int i=0; i<threads.length; i++)
4564N/A threads[i].join();
4564N/A
4564N/A if (failed)
4564N/A throw new RuntimeException("Failed: check output");
2869N/A }
2869N/A
2869N/A static class TestThread extends Thread {
2869N/A private Class<? extends LocaleServiceProvider> cls;
4564N/A private static int count;
2869N/A
2869N/A public TestThread(Class<? extends LocaleServiceProvider> providerClass) {
2869N/A cls = providerClass;
2869N/A }
2869N/A
4564N/A public TestThread() {
4564N/A int which = count++ % 3;
4564N/A switch (which) {
4564N/A case 0 : cls = LocaleNameProvider.class; break;
4564N/A case 1 : cls = TimeZoneNameProvider.class; break;
4564N/A case 2 : cls = DateFormatProvider.class; break;
4564N/A default : throw new AssertionError("Should not reach here");
4564N/A }
4564N/A }
4564N/A
2869N/A public void run() {
4564N/A try {
4564N/A LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls);
4564N/A pool.getAvailableLocales();
4564N/A } catch (Exception e) {
4564N/A System.out.println(e);
4564N/A e.printStackTrace();
4564N/A failed = true;
4564N/A }
2869N/A }
2869N/A }
2869N/A}