values[i++] = iThrowableProxy; if (iThrowableProxy instanceof ThrowableProxy) { values[i++] = ((ThrowableProxy) iThrowableProxy).getThrowable(); } else { values[i++] = null;
public LoggingEvent(String fqcn, Logger logger, Level level, String message, Throwable throwable, Object[] argArray) { this.fqnOfLoggerClass = fqcn; this.loggerName = logger.getName(); this.loggerContext = logger.getLoggerContext(); this.loggerContextVO = loggerContext.getLoggerContextRemoteView(); this.level = level; this.message = message; this.argumentArray = argArray; if (throwable == null) { throwable = extractThrowableAnRearrangeArguments(argArray); } if (throwable != null) { this.throwableProxy = new ThrowableProxy(throwable); LoggerContext lc = logger.getLoggerContext(); if (lc.isPackagingDataEnabled()) { this.throwableProxy.calculatePackagingData(); } } timeStamp = System.currentTimeMillis(); }
public void calculatePackagingData() { if (calculatedPackageData) { return; } PackagingDataCalculator pdc = this.getPackagingDataCalculator(); if (pdc != null) { calculatedPackageData = true; pdc.calculate(this); } }
this.cause = new ThrowableProxy(nested); this.cause.commonFrames = ThrowableProxyUtil.findNumberOfCommonFrames(nested.getStackTrace(), stackTraceElementProxyArray); suppressed = new ThrowableProxy[throwableSuppressed.length]; for (int i = 0; i < throwableSuppressed.length; i++) { this.suppressed[i] = new ThrowableProxy(throwableSuppressed[i]); this.suppressed[i].commonFrames = ThrowableProxyUtil.findNumberOfCommonFrames(throwableSuppressed[i].getStackTrace(), stackTraceElementProxyArray);
@Test // Test http://jira.qos.ch/browse/LBCLASSIC-125 public void noClassDefFoundError_LBCLASSIC_125Test() throws MalformedURLException { ClassLoader cl = (URLClassLoader) makeBogusClassLoader(); Thread.currentThread().setContextClassLoader(cl); Throwable t = new Throwable("x"); ThrowableProxy tp = new ThrowableProxy(t); StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray(); StackTraceElement bogusSTE = new StackTraceElement("com.Bogus", "myMethod", "myFile", 12); stepArray[0] = new StackTraceElementProxy(bogusSTE); PackagingDataCalculator pdc = tp.getPackagingDataCalculator(); // NoClassDefFoundError should be caught pdc.calculate(tp); }
@Test public void smoke() throws Exception { Throwable t = new Throwable("x"); ThrowableProxy tp = new ThrowableProxy(t); PackagingDataCalculator pdc = tp.getPackagingDataCalculator(); pdc.calculate(tp); verify(tp); tp.fullDump(); }
public void doCalculateClassPackagingData( boolean withClassPackagingCalculation) { try { throw new Exception("testing"); } catch (Throwable e) { ThrowableProxy tp = new ThrowableProxy(e); if (withClassPackagingCalculation) { PackagingDataCalculator pdc = tp.getPackagingDataCalculator(); pdc.calculate(tp); } } }
public static void build(ThrowableProxy nestedTP, Throwable nestedThrowable, ThrowableProxy parentTP) { StackTraceElement[] nestedSTE = nestedThrowable.getStackTrace(); int commonFramesCount = -1; if (parentTP != null) { commonFramesCount = findNumberOfCommonFrames(nestedSTE, parentTP.getStackTraceElementProxyArray()); } nestedTP.commonFrames = commonFramesCount; nestedTP.stackTraceElementProxyArray = steArrayToStepArray(nestedSTE); }
@Test public void testStack() { Exception ex = new UnsupportedOperationException("foo"); ex = new IllegalStateException("bar", ex); StringBuilder stackBuilder = new StringBuilder(); LoggingAppender.writeStack(new ThrowableProxy(ex), "", stackBuilder); String stack = stackBuilder.toString(); assertThat(stack).contains("java.lang.IllegalStateException: bar"); assertThat(stack).contains("caused by: java.lang.UnsupportedOperationException: foo"); assertThat(stack).contains("common frames elided"); } }
@Test public void nested() throws Exception { Throwable t = TestHelper.makeNestedException(3); ThrowableProxy tp = new ThrowableProxy(t); PackagingDataCalculator pdc = tp.getPackagingDataCalculator(); pdc.calculate(tp); verify(tp); }
public static void build(ThrowableProxy nestedTP, Throwable nestedThrowable, ThrowableProxy parentTP) { StackTraceElement[] nestedSTE = nestedThrowable.getStackTrace(); int commonFramesCount = -1; if (parentTP != null) { commonFramesCount = findNumberOfCommonFrames(nestedSTE, parentTP .getStackTraceElementProxyArray()); } nestedTP.commonFrames = commonFramesCount; nestedTP.stackTraceElementProxyArray = steArrayToStepArray(nestedSTE); }
public LoggingEvent(String fqcn, Logger logger, Level level, String message, Throwable throwable, Object[] argArray) { this.fqnOfLoggerClass = fqcn; this.loggerName = logger.getName(); this.loggerContext = logger.getLoggerContext(); this.loggerContextVO = loggerContext.getLoggerContextRemoteView(); this.level = level; this.message = message; this.argumentArray = argArray; if(throwable == null) { throwable = extractThrowableAnRearrangeArguments(argArray); } if (throwable != null) { this.throwableProxy = new ThrowableProxy(throwable); LoggerContext lc = logger.getLoggerContext(); if (lc.isPackagingDataEnabled()) { this.throwableProxy.calculatePackagingData(); } } timeStamp = System.currentTimeMillis(); }
values[i++] = iThrowableProxy; if (iThrowableProxy instanceof ThrowableProxy) { values[i++] = ((ThrowableProxy) iThrowableProxy).getThrowable(); } else { values[i++] = null;
this.cause = new ThrowableProxy(nested); this.cause.commonFrames = ThrowableProxyUtil .findNumberOfCommonFrames(nested.getStackTrace(), suppressed = new ThrowableProxy[throwableSuppressed.length]; for(int i=0;i<throwableSuppressed.length;i++) { this.suppressed[i] = new ThrowableProxy(throwableSuppressed[i]); this.suppressed[i].commonFrames = ThrowableProxyUtil .findNumberOfCommonFrames(throwableSuppressed[i].getStackTrace(),
public static void build(ThrowableProxy nestedTP, Throwable nestedThrowable, ThrowableProxy parentTP) { StackTraceElement[] nestedSTE = nestedThrowable.getStackTrace(); int commonFramesCount = -1; if (parentTP != null) { commonFramesCount = findNumberOfCommonFrames(nestedSTE, parentTP .getStackTraceElementProxyArray()); } nestedTP.commonFrames = commonFramesCount; nestedTP.stackTraceElementProxyArray = steArrayToStepArray(nestedSTE); }
public void calculatePackagingData() { if (calculatedPackageData) { return; } PackagingDataCalculator pdc = this.getPackagingDataCalculator(); if (pdc != null) { calculatedPackageData = true; pdc.calculate(this); } }
ThrowableProxy getThrowableProxy(Throwable t) { if (t == null) return null; ThrowableProxy throwableProxy = new ThrowableProxy(t); if (loggerContext.isPackagingDataEnabled()) { throwableProxy.calculatePackagingData(); } return throwableProxy; }
/** * Gets the throwable from the log event (if any) * @param event The log event * @return The throwable (or null) */ private Throwable extractThrowable(ILoggingEvent event) { IThrowableProxy throwableProxy = event.getThrowableProxy(); if (throwableProxy instanceof ThrowableProxy) { return ((ThrowableProxy) throwableProxy).getThrowable(); } return null; }
public ThrowableProxy(Throwable throwable) { this.throwable = throwable; this.className = throwable.getClass().getName(); this.message = throwable.getMessage(); this.stackTraceElementProxyArray = ThrowableProxyUtil.steArrayToStepArray(throwable .getStackTrace()); Throwable nested = throwable.getCause(); if (nested != null) { this.cause = new ThrowableProxy(nested); this.cause.commonFrames = ThrowableProxyUtil .findNumberOfCommonFrames(nested.getStackTrace(), stackTraceElementProxyArray); } }
static public void build(ThrowableProxy nestedTP, Throwable nestedThrowable, ThrowableProxy parentTP) { StackTraceElement[] nestedSTE = nestedThrowable.getStackTrace(); int commonFramesCount = -1; if (parentTP != null) { commonFramesCount = findNumberOfCommonFrames(nestedSTE, parentTP .getStackTraceElementProxyArray()); } nestedTP.commonFrames = commonFramesCount; nestedTP.stackTraceElementProxyArray = steArrayToStepArray(nestedSTE); }