Skip to content

Commit

Permalink
improve error message on UnknownGcTypeExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
chewiebug committed Aug 1, 2018
1 parent 9918095 commit c75a91b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
Expand Up @@ -601,8 +601,8 @@ protected AbstractGCEvent<?> parseLine(String line, ParseInformation pos) throws

return ae;
}
catch (RuntimeException rte) {
throw new ParseException("Error parsing entry (" + rte.toString() + ")", line, pos);
catch (RuntimeException | UnknownGcTypeException e) {
throw new ParseException(e.toString(), line, pos);
}
}

Expand Down
@@ -1,10 +1,5 @@
package com.tagtraum.perf.gcviewer.imp;

import com.tagtraum.perf.gcviewer.model.*;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.*;
import com.tagtraum.perf.gcviewer.util.NumberParser;
import com.tagtraum.perf.gcviewer.util.ParseInformation;

import java.io.IOException;
import java.io.InputStream;
import java.io.LineNumberReader;
Expand All @@ -16,6 +11,21 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.tagtraum.perf.gcviewer.model.AbstractGCEvent;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.CollectionType;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Concurrency;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.ExtendedType;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.GcPattern;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type;
import com.tagtraum.perf.gcviewer.model.ConcurrentGCEvent;
import com.tagtraum.perf.gcviewer.model.G1GcEvent;
import com.tagtraum.perf.gcviewer.model.GCEvent;
import com.tagtraum.perf.gcviewer.model.GCModel;
import com.tagtraum.perf.gcviewer.model.GCResource;
import com.tagtraum.perf.gcviewer.model.VmOperationEvent;
import com.tagtraum.perf.gcviewer.util.NumberParser;
import com.tagtraum.perf.gcviewer.util.ParseInformation;

/**
* Parses log output from Sun / Oracle Java 1.6. / 1.7.
* <p>
Expand Down Expand Up @@ -543,8 +553,8 @@ else if (type.getCollectionType().equals(CollectionType.VM_OPERATION)) {
}
return ae;
}
catch (RuntimeException rte) {
throw new ParseException(rte.toString(), line, pos);
catch (RuntimeException | UnknownGcTypeException e) {
throw new ParseException(e.toString(), line, pos);
}
}

Expand Down
@@ -1,6 +1,7 @@
package com.tagtraum.perf.gcviewer.imp;

import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
Expand Down Expand Up @@ -175,4 +176,25 @@ public void youngInitialMarkMetadataThreshold() throws Exception {
assertThat("number of errors", handler.getCount(), is(0));
assertThat("pause duration", model.get(0).getPause(), closeTo(0.0229931, 0.00000001));
}

@Test
public void doubleTimeStamp() throws Exception {
TestLogHandler handler = new TestLogHandler();
handler.setLevel(Level.WARNING);
GCResource gcResource = new GcResourceFile("byteArray");
gcResource.getLogger().addHandler(handler);

ByteArrayInputStream in = new ByteArrayInputStream(
("176020.306: 176020.306: [GC concurrent-root-region-scan-start]")
.getBytes());

DataReader reader = new DataReaderSun1_6_0G1(gcResource, in, GcLogType.SUN1_8);
GCModel model = reader.read();

assertThat("size", model.size(), is(0));
assertThat("warnings", handler.getCount(), is(1));
assertThat("log message contains line number", handler.getLogRecords().get(0).getMessage(), containsString("Line"));
assertThat("log message contains log line", handler.getLogRecords().get(0).getMessage(), containsString("176020.306: 176020.306"));

}
}

0 comments on commit c75a91b

Please sign in to comment.