From 6af00c0cac95edcd6ac063feb6cacc42906a3c16 Mon Sep 17 00:00:00 2001 From: Peter Veentjer Date: Mon, 7 Sep 2020 09:22:00 +0300 Subject: [PATCH] Made diagnostics rendering more robust In case of an exception while rendering a plugin, the number of indents is not restored to its initial value and eventually plugins will run into an IndexOutOfBoundException. This PR fixes that by resetting the number of indents before a plugin is rendered. --- .../internal/diagnostics/DiagnosticsLogWriterImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/DiagnosticsLogWriterImpl.java b/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/DiagnosticsLogWriterImpl.java index caff1b00ef00..0a588f572a82 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/DiagnosticsLogWriterImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/DiagnosticsLogWriterImpl.java @@ -214,6 +214,12 @@ private void writeKeyValueHead(String key) { } public void init(PrintWriter printWriter) { + // Reset the sectionLevel. A proper rendering of a plugin should always + // return this value to -1; but in case of an exception while rendering, + // the section level isn't reset and subsequent renderings of plugins + // will run into an IndexOutOfBoundsException. + // https://github.com/hazelcast/hazelcast/issues/14973 + sectionLevel = -1; this.printWriter = printWriter; }