[
https://issues.jboss.org/browse/SEAMCATCH-4?page=com.atlassian.jira.plugi...
]
Jason Porter edited comment on SEAMCATCH-4 at 2/19/11 2:27 PM:
---------------------------------------------------------------
Here are some examples.
1. Drop all frames in NoDefClassFoundError
{code:java}
public class NoClassFoundStackFrameFilter implements
ExceptionStackFrameFilter<NoClassDefFoundError>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
return StackFrameFilterResult.BREAK;
}
}
{code}
2. Truncate frames after a threshold (though no indication we did that we did)
{code:java}
public class TruncateExceptionStackFilter implements
ExceptionStackFrameFilter<Throwable>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
if (frame.getIterationStatus().getIndex() >= 20)
{
return StackFrameFilterResult.DROP_REMAINING;
}
return StackFrameFilterResult.INCLUDE;
}
}
{code}
3. Remove noise in between fire event and invoke observer
{code:java}
public class InvokeObserverStackFrameFilter implements
ExceptionStackFrameFilter<Throwable>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
StackTraceElement el = frame.getStackTraceElement();
if (frame.isMarkSet("event.firing"))
{
if (isReflectionInvoke(el))
{
frame.clearMark("event.firing");
return StackFrameFilterResult.DROP;
}
else
{
return StackFrameFilterResult.DROP;
}
}
else if (el.getClassName().contains(".BeanManager") &&
el.getMethodName().equals("fireEvent"))
{
frame.mark("event.firing");
return StackFrameFilterResult.INCLUDE;
}
return StackFrameFilterResult.INCLUDE;
}
private boolean isReflectionInvoke(StackTraceElement candidate)
{
return candidate.getClassName().equals(Method.class.getName())
&& candidate.getMethodName().equals("invoke");
}
}
{code}
4. Flatten reflections invoke into a single line
{code:java}
public class ReflectionInvokeStackFrameFilter implements
ExceptionStackFrameFilter<Throwable>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
if (frame.isMarkSet("reflections.invoke"))
{
if (frame.getStackTraceElement().getMethodName().startsWith("invoke")
||
frame.getStackTraceElement().getClassName().contains("_WeldClientProxy"))
{
return StackFrameFilterResult.DROP;
}
else
{
frame.clearMark("reflections.invoke");
}
}
return StackFrameFilterResult.INCLUDE;
}
}
{code}
was (Author: dan.j.allen):
Here are some examples.
1. Drop all frames in NoDefClassFoundError
public class NoClassFoundStackFrameFilter implements
ExceptionStackFrameFilter<NoClassDefFoundError>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
return StackFrameFilterResult.BREAK;
}
}
2. Truncate frames after a threshold (though no indication we did that we did)
public class TruncateExceptionStackFilter implements
ExceptionStackFrameFilter<Throwable>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
if (frame.getIterationStatus().getIndex() >= 20)
{
return StackFrameFilterResult.DROP_REMAINING;
}
return StackFrameFilterResult.INCLUDE;
}
}
3. Remove noise in between fire event and invoke observer
public class InvokeObserverStackFrameFilter implements
ExceptionStackFrameFilter<Throwable>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
StackTraceElement el = frame.getStackTraceElement();
if (frame.isMarkSet("event.firing"))
{
if (isReflectionInvoke(el))
{
frame.clearMark("event.firing");
return StackFrameFilterResult.DROP;
}
else
{
return StackFrameFilterResult.DROP;
}
}
else if (el.getClassName().contains(".BeanManager") &&
el.getMethodName().equals("fireEvent"))
{
frame.mark("event.firing");
return StackFrameFilterResult.INCLUDE;
}
return StackFrameFilterResult.INCLUDE;
}
private boolean isReflectionInvoke(StackTraceElement candidate)
{
return candidate.getClassName().equals(Method.class.getName())
&& candidate.getMethodName().equals("invoke");
}
}
4. Flatten reflections invoke into a single line
public class ReflectionInvokeStackFrameFilter implements
ExceptionStackFrameFilter<Throwable>
{
@Override
public StackFrameFilterResult process(StackFrame frame)
{
if (frame.isMarkSet("reflections.invoke"))
{
if (frame.getStackTraceElement().getMethodName().startsWith("invoke")
||
frame.getStackTraceElement().getClassName().contains("_WeldClientProxy"))
{
return StackFrameFilterResult.DROP;
}
else
{
frame.clearMark("reflections.invoke");
}
}
return StackFrameFilterResult.INCLUDE;
}
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira