Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/management/AgentCMETest.java
38833 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* Portions Copyright (c) 2012 IBM Corporation25*/2627/**28* @test29* @bug 716419130* @summary properties.putAll API may fail with ConcurrentModifcationException on multi-thread scenario31* @author Deven You32*/3334import java.util.Properties;35import sun.management.Agent;3637public class AgentCMETest {38static Class<?> agentClass;3940/**41* In sun.management.Agent.loadManagementProperties(), call42* properties.putAll API may fail with ConcurrentModifcationException if the43* system properties are modified simultaneously by another thread44*45* @param args46* @throws Exception47*/48public static void main(String[] args) throws Exception {49System.out.println("Start...");5051final Properties properties = System.getProperties();52Thread t1 = new Thread(new Runnable() {53public void run() {54for (int i = 0; i < 100; i++) {55properties.put(String.valueOf(i), "");56try {57Thread.sleep(1);58} catch (InterruptedException e) {59// do nothing60}61}62}63});64t1.start();6566for (int i = 0; i < 10000; i++) {67Agent.loadManagementProperties();68}6970System.out.println("Finished...");71}72}737475