List of usage examples for org.apache.commons.lang.exception ExceptionUtils getStackFrames
static String[] getStackFrames(String stackTrace)
Returns an array where each element is a line from the argument.
The end of line is determined by the value of SystemUtils#LINE_SEPARATOR .
Functionality shared between the getStackFrames(Throwable)
methods of this and the org.apache.commons.lang.exception.NestableDelegate classes.
From source file:org.kiji.schema.util.DebugResourceTracker.java
/** * Registers a resource that should be cleaned up and removed before JVM shutdown. When using * reference level tracking, the message and the current stack trace will be logged. * * @param resource Object which should be cleaned up before JVM shutdown. * @param message string which will be logged along with the current stack trace if the resource * is not closed before shutdown. A good example of this error message is the stack trace at * the time the object was created.// w ww. ja v a 2 s.c om */ public void registerResource(final Object resource, final String message) { switch (TRACKING_LEVEL) { case NONE: break; case COUNTER: { mCounter.incrementAndGet(); break; } case REFERENCES: { // Skip two stack frames. One for the throwable, one for this method. final String stackTrace = Joiner.on('\n') .join(Iterables.skip(Lists.newArrayList(ExceptionUtils.getStackFrames(new Throwable())), 2)); mCounter.incrementAndGet(); mReferenceTracker.registerResource(resource, message, stackTrace); break; } default: throw new InternalKijiError( String.format("Unknown DebugResourceTracker.TrackingType: %s", TRACKING_LEVEL)); } }
From source file:org.kiji.schema.util.DebugResourceTracker.java
/** * Registers a resource that should be cleaned up and removed before JVM shutdown. When using * reference level tracking, the message will be the {@link #toString()} of the resource, and the * current stack trace.// www . j a va 2s .co m * <p> * This method will call {@link #toString()} on the passed in resource, so it must be in a valid * state. * * @param resource Object which should be cleaned up before JVM shutdown. */ public void registerResource(final Object resource) { switch (TRACKING_LEVEL) { case NONE: break; case COUNTER: { mCounter.incrementAndGet(); break; } case REFERENCES: { // Skip two stack frames. One for the throwable, one for this method. final String stackTrace = Joiner.on('\n') .join(Iterables.skip(Lists.newArrayList(ExceptionUtils.getStackFrames(new Throwable())), 2)); mCounter.incrementAndGet(); mReferenceTracker.registerResource(resource, resource.toString(), stackTrace); break; } default: throw new InternalKijiError( String.format("Unknown DebugResourceTracker.TrackingType: %s", TRACKING_LEVEL)); } }
From source file:org.marketcetera.util.ws.wrappers.RemoteProperties.java
/** * Creates a new container for a {@link RemoteException} that * wraps the given throwable.//from w ww .j a v a 2 s .c o m * * @param throwable The throwable, which may be null. */ public RemoteProperties(Throwable throwable) { setTransientThrowable(throwable); if (getTransientThrowable() == null) { return; } setWrapper(new SerWrapper<Throwable>(getTransientThrowable())); setTraceCapture(ExceptionUtils.getStackFrames(getTransientThrowable())); if (getTransientThrowable() instanceof I18NThrowable) { setServerMessage(((I18NThrowable) getTransientThrowable()).getLocalizedDetail()); } else { setServerMessage(getTransientThrowable().getLocalizedMessage()); } setServerString(getTransientThrowable().toString()); setServerName(getTransientThrowable().getClass().getName()); }
From source file:org.marketcetera.util.ws.wrappers.WrapperTestBase.java
protected static void assertThrowable(Throwable expected, Throwable actual, boolean proxyUsed) { if ((actual == null) || (expected == null)) { assertEquals(expected, actual);/*from w ww. ja v a 2s .co m*/ return; } if (proxyUsed) { assertEquals(RemoteProxyException.class, actual.getClass()); if (expected instanceof I18NThrowable) { assertEquals(((I18NThrowable) expected).getLocalizedDetail(), actual.getMessage()); ActiveLocale.setProcessLocale(Locale.FRENCH); assertEquals(((I18NThrowable) expected).getLocalizedDetail(), actual.getMessage()); ActiveLocale.setProcessLocale(Locale.ROOT); } else { assertEquals(expected.getLocalizedMessage(), actual.getMessage()); } } else { assertEquals(expected.getClass(), actual.getClass()); assertEquals(expected.getMessage(), actual.getMessage()); } assertEquals(expected.toString(), actual.toString()); assertArrayEquals(ExceptionUtils.getStackFrames(expected), ExceptionUtils.getStackFrames(actual)); }