< prev index next >

test/jdk/java/util/concurrent/locks/Lock/TimedAcquireLeak.java

Print this page
rev 51731 : imported patch 8210732


   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 6460501 6236036 6500694 6490770
  27  * @summary Repeated failed timed waits shouldn't leak memory
  28  * @library /lib/testlibrary/
  29  * @author Martin Buchholz
  30  */
  31 
  32 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  33 import static java.util.concurrent.TimeUnit.NANOSECONDS;
  34 
  35 import java.io.File;
  36 import java.io.FileOutputStream;
  37 import java.io.IOException;
  38 import java.io.InputStream;
  39 import java.io.InputStreamReader;
  40 import java.io.OutputStream;
  41 import java.io.PrintStream;
  42 import java.io.Reader;
  43 import java.lang.ref.ReferenceQueue;
  44 import java.lang.ref.WeakReference;
  45 import java.util.concurrent.BlockingQueue;
  46 import java.util.concurrent.Callable;
  47 import java.util.concurrent.CountDownLatch;
  48 import java.util.concurrent.CyclicBarrier;
  49 import java.util.concurrent.ExecutorService;
  50 import java.util.concurrent.Executors;
  51 import java.util.concurrent.Future;
  52 import java.util.concurrent.LinkedBlockingQueue;
  53 import java.util.concurrent.Semaphore;
  54 import java.util.concurrent.ThreadLocalRandom;
  55 import java.util.concurrent.locks.ReentrantLock;
  56 import java.util.concurrent.locks.ReentrantReadWriteLock;
  57 import java.util.regex.Matcher;
  58 import java.util.regex.Pattern;
  59 import jdk.testlibrary.Utils;
  60 
  61 public class TimedAcquireLeak {
  62     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
  63 
  64     static String javahome() {
  65         String jh = System.getProperty("java.home");
  66         return (jh.endsWith("jre")) ? jh.substring(0, jh.length() - 4) : jh;
  67     }
  68 
  69     static final File bin = new File(javahome(), "bin");
  70 
  71     static String javaProgramPath(String programName) {
  72         return new File(bin, programName).getPath();
  73     }
  74 
  75     static final String java = javaProgramPath("java");
  76     static final String jmap = javaProgramPath("jmap");
  77     static final String jps  = javaProgramPath("jps");
  78 
  79     static String outputOf(Reader r) throws IOException {




   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 6460501 6236036 6500694 6490770
  27  * @summary Repeated failed timed waits shouldn't leak memory
  28  * @library /test/lib
  29  * @author Martin Buchholz
  30  */
  31 
  32 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  33 import static java.util.concurrent.TimeUnit.NANOSECONDS;
  34 
  35 import java.io.File;
  36 import java.io.FileOutputStream;
  37 import java.io.IOException;
  38 import java.io.InputStream;
  39 import java.io.InputStreamReader;
  40 import java.io.OutputStream;
  41 import java.io.PrintStream;
  42 import java.io.Reader;
  43 import java.lang.ref.ReferenceQueue;
  44 import java.lang.ref.WeakReference;
  45 import java.util.concurrent.BlockingQueue;
  46 import java.util.concurrent.Callable;
  47 import java.util.concurrent.CountDownLatch;
  48 import java.util.concurrent.CyclicBarrier;
  49 import java.util.concurrent.ExecutorService;
  50 import java.util.concurrent.Executors;
  51 import java.util.concurrent.Future;
  52 import java.util.concurrent.LinkedBlockingQueue;
  53 import java.util.concurrent.Semaphore;
  54 import java.util.concurrent.ThreadLocalRandom;
  55 import java.util.concurrent.locks.ReentrantLock;
  56 import java.util.concurrent.locks.ReentrantReadWriteLock;
  57 import java.util.regex.Matcher;
  58 import java.util.regex.Pattern;
  59 import jdk.test.lib.Utils;
  60 
  61 public class TimedAcquireLeak {
  62     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
  63 
  64     static String javahome() {
  65         String jh = System.getProperty("java.home");
  66         return (jh.endsWith("jre")) ? jh.substring(0, jh.length() - 4) : jh;
  67     }
  68 
  69     static final File bin = new File(javahome(), "bin");
  70 
  71     static String javaProgramPath(String programName) {
  72         return new File(bin, programName).getPath();
  73     }
  74 
  75     static final String java = javaProgramPath("java");
  76     static final String jmap = javaProgramPath("jmap");
  77     static final String jps  = javaProgramPath("jps");
  78 
  79     static String outputOf(Reader r) throws IOException {


< prev index next >