Skip to content

Commit c75a91b

Browse files
committed
improve error message on UnknownGcTypeExceptions
1 parent 9918095 commit c75a91b

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderSun1_6_0.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ protected AbstractGCEvent<?> parseLine(String line, ParseInformation pos) throws
601601

602602
return ae;
603603
}
604-
catch (RuntimeException rte) {
605-
throw new ParseException("Error parsing entry (" + rte.toString() + ")", line, pos);
604+
catch (RuntimeException | UnknownGcTypeException e) {
605+
throw new ParseException(e.toString(), line, pos);
606606
}
607607
}
608608

src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderSun1_6_0G1.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
package com.tagtraum.perf.gcviewer.imp;
22

3-
import com.tagtraum.perf.gcviewer.model.*;
4-
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.*;
5-
import com.tagtraum.perf.gcviewer.util.NumberParser;
6-
import com.tagtraum.perf.gcviewer.util.ParseInformation;
7-
83
import java.io.IOException;
94
import java.io.InputStream;
105
import java.io.LineNumberReader;
@@ -16,6 +11,21 @@
1611
import java.util.regex.Matcher;
1712
import java.util.regex.Pattern;
1813

14+
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent;
15+
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.CollectionType;
16+
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Concurrency;
17+
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.ExtendedType;
18+
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.GcPattern;
19+
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type;
20+
import com.tagtraum.perf.gcviewer.model.ConcurrentGCEvent;
21+
import com.tagtraum.perf.gcviewer.model.G1GcEvent;
22+
import com.tagtraum.perf.gcviewer.model.GCEvent;
23+
import com.tagtraum.perf.gcviewer.model.GCModel;
24+
import com.tagtraum.perf.gcviewer.model.GCResource;
25+
import com.tagtraum.perf.gcviewer.model.VmOperationEvent;
26+
import com.tagtraum.perf.gcviewer.util.NumberParser;
27+
import com.tagtraum.perf.gcviewer.util.ParseInformation;
28+
1929
/**
2030
* Parses log output from Sun / Oracle Java 1.6. / 1.7.
2131
* <p>
@@ -543,8 +553,8 @@ else if (type.getCollectionType().equals(CollectionType.VM_OPERATION)) {
543553
}
544554
return ae;
545555
}
546-
catch (RuntimeException rte) {
547-
throw new ParseException(rte.toString(), line, pos);
556+
catch (RuntimeException | UnknownGcTypeException e) {
557+
throw new ParseException(e.toString(), line, pos);
548558
}
549559
}
550560

src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderSun1_8_0G1.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tagtraum.perf.gcviewer.imp;
22

33
import static org.hamcrest.Matchers.closeTo;
4+
import static org.hamcrest.Matchers.containsString;
45
import static org.hamcrest.Matchers.is;
56
import static org.junit.Assert.assertEquals;
67
import static org.junit.Assert.assertThat;
@@ -175,4 +176,25 @@ public void youngInitialMarkMetadataThreshold() throws Exception {
175176
assertThat("number of errors", handler.getCount(), is(0));
176177
assertThat("pause duration", model.get(0).getPause(), closeTo(0.0229931, 0.00000001));
177178
}
179+
180+
@Test
181+
public void doubleTimeStamp() throws Exception {
182+
TestLogHandler handler = new TestLogHandler();
183+
handler.setLevel(Level.WARNING);
184+
GCResource gcResource = new GcResourceFile("byteArray");
185+
gcResource.getLogger().addHandler(handler);
186+
187+
ByteArrayInputStream in = new ByteArrayInputStream(
188+
("176020.306: 176020.306: [GC concurrent-root-region-scan-start]")
189+
.getBytes());
190+
191+
DataReader reader = new DataReaderSun1_6_0G1(gcResource, in, GcLogType.SUN1_8);
192+
GCModel model = reader.read();
193+
194+
assertThat("size", model.size(), is(0));
195+
assertThat("warnings", handler.getCount(), is(1));
196+
assertThat("log message contains line number", handler.getLogRecords().get(0).getMessage(), containsString("Line"));
197+
assertThat("log message contains log line", handler.getLogRecords().get(0).getMessage(), containsString("176020.306: 176020.306"));
198+
199+
}
178200
}

0 commit comments

Comments
 (0)