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

Print this page




  47         return new File(bin, programName).getPath();
  48     }
  49 
  50     static final String java = javaProgramPath("java");
  51     static final String jmap = javaProgramPath("jmap");
  52     static final String jps  = javaProgramPath("jps");
  53 
  54     static String outputOf(Reader r) throws IOException {
  55         final StringBuilder sb = new StringBuilder();
  56         final char[] buf = new char[1024];
  57         int n;
  58         while ((n = r.read(buf)) > 0)
  59             sb.append(buf, 0, n);
  60         return sb.toString();
  61     }
  62 
  63     static String outputOf(InputStream is) throws IOException {
  64         return outputOf(new InputStreamReader(is, "UTF-8"));
  65     }
  66 
  67     final static ExecutorService drainers = Executors.newFixedThreadPool(12);
  68     static Future<String> futureOutputOf(final InputStream is) {
  69         return drainers.submit(
  70             new Callable<String>() { public String call() throws IOException {
  71                     return outputOf(is); }});}
  72 
  73     static String outputOf(final Process p) {
  74         try {
  75             Future<String> outputFuture = futureOutputOf(p.getInputStream());
  76             Future<String> errorFuture = futureOutputOf(p.getErrorStream());
  77             final String output = outputFuture.get();
  78             final String error = errorFuture.get();
  79             // Check for successful process completion
  80             equal(error, "");
  81             equal(p.waitFor(), 0);
  82             equal(p.exitValue(), 0);
  83             return output;
  84         } catch (Throwable t) { unexpected(t); throw new Error(t); }
  85     }
  86 
  87     static String commandOutputOf(String... cmd) {




  47         return new File(bin, programName).getPath();
  48     }
  49 
  50     static final String java = javaProgramPath("java");
  51     static final String jmap = javaProgramPath("jmap");
  52     static final String jps  = javaProgramPath("jps");
  53 
  54     static String outputOf(Reader r) throws IOException {
  55         final StringBuilder sb = new StringBuilder();
  56         final char[] buf = new char[1024];
  57         int n;
  58         while ((n = r.read(buf)) > 0)
  59             sb.append(buf, 0, n);
  60         return sb.toString();
  61     }
  62 
  63     static String outputOf(InputStream is) throws IOException {
  64         return outputOf(new InputStreamReader(is, "UTF-8"));
  65     }
  66 
  67     static final ExecutorService drainers = Executors.newFixedThreadPool(12);
  68     static Future<String> futureOutputOf(final InputStream is) {
  69         return drainers.submit(
  70             new Callable<String>() { public String call() throws IOException {
  71                     return outputOf(is); }});}
  72 
  73     static String outputOf(final Process p) {
  74         try {
  75             Future<String> outputFuture = futureOutputOf(p.getInputStream());
  76             Future<String> errorFuture = futureOutputOf(p.getErrorStream());
  77             final String output = outputFuture.get();
  78             final String error = errorFuture.get();
  79             // Check for successful process completion
  80             equal(error, "");
  81             equal(p.waitFor(), 0);
  82             equal(p.exitValue(), 0);
  83             return output;
  84         } catch (Throwable t) { unexpected(t); throw new Error(t); }
  85     }
  86 
  87     static String commandOutputOf(String... cmd) {