8220555: JFR tool shows potentially misleading message when it cannot access a file
authorysuenaga
Sat, 16 Mar 2019 21:27:15 +0900
changeset 54153 4985c8ca55b9
parent 54152 5274462d5725
child 54154 1caf2daef7cf
8220555: JFR tool shows potentially misleading message when it cannot access a file Reviewed-by: egahlin, mseledtsov
src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Command.java
test/jdk/jdk/jfr/tool/TestPrint.java
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Command.java	Sat Mar 16 02:08:10 2019 +0100
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Command.java	Sat Mar 16 21:27:15 2019 +0900
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -243,7 +243,7 @@
             }
             rad.read(); // try to read 1 byte
         } catch (FileNotFoundException e) {
-            throw new UserDataException("could not find file '" + path + "'");
+            throw new UserDataException("could not open file " + e.getMessage());
         } catch (IOException e) {
             throw new UserDataException("i/o error reading file '" + path + "', " + e.getMessage());
         }
--- a/test/jdk/jdk/jfr/tool/TestPrint.java	Sat Mar 16 02:08:10 2019 +0100
+++ b/test/jdk/jdk/jfr/tool/TestPrint.java	Sat Mar 16 21:27:15 2019 +0900
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -48,7 +48,7 @@
         output.shouldContain("missing file");
 
         output = ExecuteHelper.jfr("print", "missing.jfr");
-        output.shouldContain("could not find file ");
+        output.shouldContain("could not open file ");
 
         Path file = Utils.createTempFile("faked-print-file",  ".jfr");
         FileWriter fw = new FileWriter(file.toFile());