changeset 48494:d53732d23ade

8031482: Some jcmds generate output with a \n as a separator rather than \r\n on Windows Reviewed-by: cjplummer, sspitsyn, dholmes
author gadams
date Sat, 13 Jan 2018 18:33:35 -0500
parents fb56735cb46a
children a65e8281b27c
files test/jdk/ProblemList.txt test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
diffstat 2 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/ProblemList.txt	Fri Jan 12 14:33:00 2018 -0800
+++ b/test/jdk/ProblemList.txt	Sat Jan 13 18:33:35 2018 -0500
@@ -1,6 +1,6 @@
 ###########################################################################
 #
-# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -351,8 +351,6 @@
 
 # svc_tools
 
-sun/tools/jcmd/TestJcmdSanity.java                              8031482 windows-all
-
 sun/tools/jstat/jstatClassloadOutput1.sh                        8173942 generic-all
 
 sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java    8057732 generic-all
--- a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java	Fri Jan 12 14:33:00 2018 -0800
+++ b/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java	Sat Jan 13 18:33:35 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,16 @@
 
 import static jdk.testlibrary.Asserts.*;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
 
 /**
  * Utility class for verifying output and exit value from a {@code Process}.
@@ -446,8 +450,9 @@
 
 
     /**
-     * Get the contents of the output buffer (stdout and stderr) as list of strings.
-     * Output will be split by system property 'line.separator'.
+     * Get the contents of the output buffer (stdout and stderr)
+     * as a list of strings. Output will be split at new-lines as
+     * recognized by java.io.BufferedReader.readLine().
      *
      * @return Contents of the output buffer as list of strings
      */
@@ -456,12 +461,8 @@
     }
 
     private List<String> asLines(String buffer) {
-        List<String> l = new ArrayList<>();
-        String[] a = buffer.split(Utils.NEW_LINE);
-        for (String string : a) {
-            l.add(string);
-        }
-        return l;
+        return new BufferedReader(new StringReader(buffer))
+            .lines().collect(Collectors.toList());
     }
 
     /**