8195819: Remove recording=x from jcmd JFR.check output
authoregahlin
Wed, 23 May 2018 00:21:58 +0200
changeset 50226 408021edf22f
parent 50225 2942ae532175
child 50227 7b259287cdd2
8195819: Remove recording=x from jcmd JFR.check output Reviewed-by: mgronlun
src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java
src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java
src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java
test/jdk/jdk/jfr/jcmd/JcmdAsserts.java
test/jdk/jdk/jfr/jcmd/JcmdHelper.java
test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java	Tue May 22 23:27:54 2018 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java	Wed May 23 00:21:58 2018 +0200
@@ -32,6 +32,7 @@
 import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import jdk.jfr.FlightRecorder;
@@ -105,7 +106,7 @@
 
     protected final List<Recording> getRecordings() {
         List<Recording> list = new ArrayList<>(getFlightRecorder().getRecordings());
-        Collections.sort(list, (a, b) -> a.getName().compareTo(b.getName()));
+        Collections.sort(list, Comparator.comparing(Recording::getId));
         return list;
     }
 
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java	Tue May 22 23:27:54 2018 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java	Wed May 23 00:21:58 2018 +0200
@@ -99,8 +99,7 @@
     }
 
     private void printGeneral(Recording recording) {
-        String format = "Recording: recording=%d name=\"%s\"";
-        print(format, recording.getId(), recording.getName());
+        print("Recording " + recording.getId() + ": name=" + recording.getName());
 
         Duration duration = recording.getDuration();
         if (duration != null) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java	Tue May 22 23:27:54 2018 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java	Wed May 23 00:21:58 2018 +0200
@@ -125,9 +125,7 @@
         }
 
         Recording recording = new Recording();
-        if (name == null) {
-            recording.setName("Recording-" + recording.getId());
-        } else {
+        if (name != null) {
             recording.setName(name);
         }
 
--- a/test/jdk/jdk/jfr/jcmd/JcmdAsserts.java	Tue May 22 23:27:54 2018 +0200
+++ b/test/jdk/jdk/jfr/jcmd/JcmdAsserts.java	Wed May 23 00:21:58 2018 +0200
@@ -102,18 +102,18 @@
 
     public static void assertRecordingIsUnstarted(OutputAnalyzer output,
             String name, String duration) {
-        output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
-                + "\"\\s+duration=" + duration + "\\s+.*\\W{1}unstarted\\W{1}");
+        output.stdoutShouldMatch("^Recording \\d+: name=" + name
+                + " duration=" + duration + " .*\\W{1}unstarted\\W{1}");
     }
 
     public static void assertRecordingIsStopped(OutputAnalyzer output, String name) {
-        output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
-                + "\"\\s+.*\\W{1}stopped\\W{1}");
+        output.stdoutShouldMatch("^Recording \\d+: name=" + name
+                + " .*\\W{1}stopped\\W{1}");
     }
 
     public static void assertRecordingIsStopped(OutputAnalyzer output, String name, String duration) {
-        output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
-                + "\"\\s+duration=" + duration + "\\s+.*\\W{1}stopped\\W{1}");
+        output.stdoutShouldMatch("^Recording \\d+: name=" + name
+                + " duration=" + duration + " .*\\W{1}stopped\\W{1}");
     }
 
     public static void assertStartTimeGreaterOrEqualThanMBeanValue(String name,
--- a/test/jdk/jdk/jfr/jcmd/JcmdHelper.java	Tue May 22 23:27:54 2018 +0200
+++ b/test/jdk/jdk/jfr/jcmd/JcmdHelper.java	Wed May 23 00:21:58 2018 +0200
@@ -43,9 +43,9 @@
             OutputAnalyzer output = jcmdCheck(name, false);
             try {
                 // The expected output can look like this:
-                // Recording: recording=1 name="Recording 1" (running)
-                output.shouldMatch("^Recording: recording=\\d+\\s+name=\"" + name
-                        + "\".*\\W{1}running\\W{1}");
+                // Recording 1: name=1 (running)
+                output.shouldMatch("^Recording \\d+: name=" + name
+                        + " .*\\W{1}running\\W{1}");
                 return;
             } catch (RuntimeException e) {
                 if (System.currentTimeMillis() > timeoutAt) {
@@ -56,19 +56,6 @@
         }
     }
 
-    // Wait until default recording's state became running
-    public static void waitUntilDefaultRecordingRunning() throws Exception {
-        while (true) {
-            OutputAnalyzer output = jcmd("JFR.check", "recording=0");
-            try {
-                output.shouldContain("Recording: recording=0 name=\"HotSpot default\" (running)");
-                return;
-            } catch (RuntimeException e) {
-                Thread.sleep(100);
-            }
-        }
-    }
-
     public static void stopAndCheck(String name) throws Exception {
         jcmd("JFR.stop", "name=\"" + name + "\"");
         assertRecordingNotRunning(name);
--- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java	Tue May 22 23:27:54 2018 +0200
+++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartStopDefault.java	Wed May 23 00:21:58 2018 +0200
@@ -49,7 +49,6 @@
         JcmdAsserts.assertRecordingHasStarted(output);
 
         String name = parseRecordingName(output);
-        name= "Recording-" + name;
         JcmdHelper.waitUntilRunning(name);
 
         output = JcmdHelper.jcmd("JFR.dump",