@Test public void testSimpleStackTrace() { String input = "org.apache.commons.lang3.SerializationException: ClassNotFoundException " + "while reading cloned object data\n" + "\tat org.apache.commons.lang3.SerializationUtils.clone(SerializationUtils.java:99)\n" + "\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" + "\tat sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)\n" + "\t... 44 more"; List<CrashStackTrace> stackTraces = StackTracesParsing.parseStackTraces(input); assertThat(stackTraces, hasSize(1)); CrashStackTrace st = stackTraces.get(0); LOG.trace("Stack trace is {}", st); assertThat(st.getExceptionClass(), equalTo("org.apache.commons.lang3.SerializationException")); assertThat(st.getErrorMessage(), equalTo("ClassNotFoundException while reading cloned object data")); assertThat(st.highestFrameLevel(), equalTo(4)); assertThat(st.getFrame(1), equalTo(new Frame("org.apache.commons.lang3.SerializationUtils", "clone", "SerializationUtils.java", 99))); assertThat(st.getFrame(2), equalTo(new Frame("sun.reflect.NativeMethodAccessorImpl", "invoke0", null, Frame.IS_NATIVE))); assertThat(st.getFrame(3), equalTo(new Frame("sun.reflect.GeneratedMethodAccessor4", "invoke", null, Frame.IS_UNKNOWN))); assertThat(st.getFrame(4), equalTo(new EllipsisFrame(44))); }
public static List<CrashStackTrace> parseStackTraces(String input){ CharStream text = CharStreams.fromString(input); StackTracesLexer lexer = new StackTracesLexer(text); CommonTokenStream tokens = new CommonTokenStream(lexer); StackTracesParser parser = new StackTracesParser(tokens); StackTracesParser.StackTracesContext tree = parser.stackTraces(); StackTracesCollectorListener listener = new StackTracesCollectorListener(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(listener, tree); return listener.getStackTraces(); }
StackTracesParsing { public static List<CrashStackTrace> parseStackTraces(String input){ CharStream text = CharStreams.fromString(input); StackTracesLexer lexer = new StackTracesLexer(text); CommonTokenStream tokens = new CommonTokenStream(lexer); StackTracesParser parser = new StackTracesParser(tokens); StackTracesParser.StackTracesContext tree = parser.stackTraces(); StackTracesCollectorListener listener = new StackTracesCollectorListener(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(listener, tree); return listener.getStackTraces(); } }
StackTracesParsing { public static List<CrashStackTrace> parseStackTraces(String input){ CharStream text = CharStreams.fromString(input); StackTracesLexer lexer = new StackTracesLexer(text); CommonTokenStream tokens = new CommonTokenStream(lexer); StackTracesParser parser = new StackTracesParser(tokens); StackTracesParser.StackTracesContext tree = parser.stackTraces(); StackTracesCollectorListener listener = new StackTracesCollectorListener(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(listener, tree); return listener.getStackTraces(); }  }
StackTracesParsing { public static List<CrashStackTrace> parseStackTraces(String input){ CharStream text = CharStreams.fromString(input); StackTracesLexer lexer = new StackTracesLexer(text); CommonTokenStream tokens = new CommonTokenStream(lexer); StackTracesParser parser = new StackTracesParser(tokens); StackTracesParser.StackTracesContext tree = parser.stackTraces(); StackTracesCollectorListener listener = new StackTracesCollectorListener(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(listener, tree); return listener.getStackTraces(); }  static List<CrashStackTrace> parseStackTraces(String input); }
StackTracesParsing { public static List<CrashStackTrace> parseStackTraces(String input){ CharStream text = CharStreams.fromString(input); StackTracesLexer lexer = new StackTracesLexer(text); CommonTokenStream tokens = new CommonTokenStream(lexer); StackTracesParser parser = new StackTracesParser(tokens); StackTracesParser.StackTracesContext tree = parser.stackTraces(); StackTracesCollectorListener listener = new StackTracesCollectorListener(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(listener, tree); return listener.getStackTraces(); }  static List<CrashStackTrace> parseStackTraces(String input);  }