From ddcfbec5692f57f0570534c680f3cdcd7dc9582e Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 6 Aug 2020 15:53:11 -0700 Subject: [PATCH] Add assert message for multiple lines in osprobe (#60796) Several /proc files are expected to contain a single line. We assert on this in tests, but the contents of the file are lost and the assertion therefore lacks important information to debug why the file appeared to have multiple lines. This commit dumps the contents of the file on assertion failure. relates #59284 --- server/src/main/java/org/elasticsearch/monitor/os/OsProbe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/monitor/os/OsProbe.java b/server/src/main/java/org/elasticsearch/monitor/os/OsProbe.java index 9bf9eb559ad..00bde057ca8 100644 --- a/server/src/main/java/org/elasticsearch/monitor/os/OsProbe.java +++ b/server/src/main/java/org/elasticsearch/monitor/os/OsProbe.java @@ -233,7 +233,7 @@ public class OsProbe { */ private String readSingleLine(final Path path) throws IOException { final List lines = Files.readAllLines(path); - assert lines != null && lines.size() == 1; + assert lines.size() == 1 : String.join("\n", lines); return lines.get(0); }