From 4a09773cd9e70557428d2686e166cdc8fee3eae2 Mon Sep 17 00:00:00 2001 From: chewiebug Date: Tue, 12 Oct 2021 18:25:58 +0200 Subject: [PATCH] also accept "][safepoint" as indicator of java unified logging format --- .../com/tagtraum/perf/gcviewer/imp/DataReaderFactory.java | 5 +++-- .../tagtraum/perf/gcviewer/imp/TestDataReaderFactory.java | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderFactory.java b/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderFactory.java index 8664d17d..36c4f38d 100644 --- a/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderFactory.java +++ b/src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderFactory.java @@ -152,8 +152,9 @@ else if (s.contains(" - else if (s.contains("][gc")) { + // ...][info][gc ] + // or ...][info][safepoint ] Using java unified jvm logging format + else if (s.contains("][gc") || s.contains("][safepoint")) { if (getLogger().isLoggable(Level.INFO)) getLogger().info("File format: Oracle / OpenJDK unified jvm logging"); return new DataReaderUnifiedJvmLogging(gcResource, in); } diff --git a/src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderFactory.java b/src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderFactory.java index 9ea33971..cb44688a 100644 --- a/src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderFactory.java +++ b/src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderFactory.java @@ -373,4 +373,12 @@ public void testOracleShenandoahJ8Simple() throws Exception { assertDataReader(DataReaderSun1_6_0.class, dr.getClass()); } + @Test + public void testOpenJdkJulRollover() throws IOException { + DataReaderFactory factory = new DataReaderFactory(); + DataReader dr = factory.getDataReader(new GcResourceFile("byteArray"), new ByteArrayInputStream(( + "[2019-09-17T20:20:29.824+0000][19.163s][info ][safepoint ] Total time for which application threads were stopped: 0.0047914 seconds, Stopping threads took: 0.0000103 seconds\n\n").getBytes())); + assertDataReader(DataReaderUnifiedJvmLogging.class, dr.getClass()); + } + }