From 4c078f48dab80d83d2f22f87230d4532098cae22 Mon Sep 17 00:00:00 2001 From: Gary Adams Date: Sat, 13 Jan 2018 18:33:35 -0500 Subject: [PATCH] 8031482: Some jcmds generate output with a \n as a separator rather than \r\n on Windows Reviewed-by: cjplummer, sspitsyn, dholmes --- test/jdk/ProblemList.txt | 4 +--- .../jdk/testlibrary/OutputAnalyzer.java | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index d33f9ab612c..e43caa37481 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -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 @@ com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows- # 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 diff --git a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java b/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java index 1a641efde90..5c2c6b27f0a 100644 --- a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java +++ b/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java @@ -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 @@ package jdk.testlibrary; 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 @@ public final class OutputAnalyzer { /** - * 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 @@ public final class OutputAnalyzer { } private List asLines(String buffer) { - List 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()); } /**