use of org.gridkit.jvmtool.event.ErrorHandler in project jvm-tools by aragozin.
the class ThreadDumpSource method getUnclassifiedReader.
public EventReader<ThreadSnapshotEvent> getUnclassifiedReader() {
if (files == null) {
host.fail("No input files provided, used -f option");
}
final Iterator<String> it = files.iterator();
ChainedEventReader<Event> reader = new ChainedEventReader<Event>() {
@Override
protected EventReader<Event> produceNext() {
return it.hasNext() ? open(it.next()) : null;
}
private EventReader<Event> open(String next) {
try {
return ThreadEventCodec.createEventReader(new FileInputStream(next));
} catch (IOException e) {
return new SingleEventReader<Event>(new SimpleErrorEvent(e));
}
}
};
ShieldedEventReader<ThreadSnapshotEvent> shielderReader = new ShieldedEventReader<ThreadSnapshotEvent>(reader, ThreadSnapshotEvent.class, new ErrorHandler() {
@Override
public void onException(Exception e) {
System.err.println("Stream reader error: " + e);
}
});
return shielderReader;
}
Aggregations