test/java/util/logging/LoggerResourceBundleRace.java

Print this page
rev 6099 : 8003380: Compiler warnings in logging test code
Summary: Use generics, suppress warnings where appropriate, remove unused imports, etc.
Reviewed-by: lancea, chegar
   1 /*
   2  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug     7045594
  27  * @summary ResourceBundle setting race in Logger.getLogger(name, rbName)
  28  * @author  Daniel D. Daugherty
  29  * @build RacingThreadsTest LoggerResourceBundleRace
  30  * @run main LoggerResourceBundleRace
  31  */
  32 
  33 import java.util.concurrent.atomic.AtomicInteger;
  34 import java.util.ListResourceBundle;
  35 import java.util.logging.Logger;
  36 import java.util.MissingResourceException;
  37 import java.util.ResourceBundle;

  38 
  39 
  40 public class LoggerResourceBundleRace extends RacingThreadsTest {
  41     private final static int N_LOOPS   = 500000;   // # of race loops
  42     private final static int N_SECS    = 15;       // # of secs to run test
  43     // # of parallel threads; must match number of MyResources inner classes
  44     private final static int N_THREADS = 3;
  45 
  46     private final static String LOGGER_PREFIX = "myLogger-";
  47     private final static String RESOURCE_PREFIX
  48         = "LoggerResourceBundleRace$MyResources";
  49     // these counters are AtomicInteger since any worker thread can increment
  50     private final static AtomicInteger iaeCnt = new AtomicInteger();
  51     private final static AtomicInteger worksCnt = new AtomicInteger();
  52 
  53     Logger dummy;   // dummy Logger
  54 
  55     LoggerResourceBundleRace(String name, int n_threads, int n_loops,
  56         int n_secs) {
  57         super(name, n_threads, n_loops, n_secs);


   1 /*
   2  * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug     7045594
  27  * @summary ResourceBundle setting race in Logger.getLogger(name, rbName)
  28  * @author  Daniel D. Daugherty
  29  * @build RacingThreadsTest LoggerResourceBundleRace
  30  * @run main LoggerResourceBundleRace
  31  */
  32 

  33 import java.util.ListResourceBundle;

  34 import java.util.MissingResourceException;
  35 import java.util.concurrent.atomic.AtomicInteger;
  36 import java.util.logging.Logger;
  37 
  38 
  39 public class LoggerResourceBundleRace extends RacingThreadsTest {
  40     private final static int N_LOOPS   = 500000;   // # of race loops
  41     private final static int N_SECS    = 15;       // # of secs to run test
  42     // # of parallel threads; must match number of MyResources inner classes
  43     private final static int N_THREADS = 3;
  44 
  45     private final static String LOGGER_PREFIX = "myLogger-";
  46     private final static String RESOURCE_PREFIX
  47         = "LoggerResourceBundleRace$MyResources";
  48     // these counters are AtomicInteger since any worker thread can increment
  49     private final static AtomicInteger iaeCnt = new AtomicInteger();
  50     private final static AtomicInteger worksCnt = new AtomicInteger();
  51 
  52     Logger dummy;   // dummy Logger
  53 
  54     LoggerResourceBundleRace(String name, int n_threads, int n_loops,
  55         int n_secs) {
  56         super(name, n_threads, n_loops, n_secs);