[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.0-12-g01ae278

Gitbot git-noreply at pixie.qos.ch
Fri Nov 4 19:01:32 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  01ae278bdf133e73f7676eebf957d07eca173a03 (commit)
       via  ccadbcf3824fa4daf2d00411fb00f22bc0fc0672 (commit)
       via  05ac03fff7d519b46e1016e2790eaa1269cb1586 (commit)
       via  1bb29a6050a471e7b65d97de9a73af7f8d400503 (commit)
      from  be9513c71eb0ed9869f6269b01dd0151c114a169 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=01ae278bdf133e73f7676eebf957d07eca173a03
http://github.com/ceki/logback/commit/01ae278bdf133e73f7676eebf957d07eca173a03

commit 01ae278bdf133e73f7676eebf957d07eca173a03
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Fri Nov 4 19:01:04 2011 +0100

    typo fix

diff --git a/logback-site/src/site/pages/manual/introduction.html b/logback-site/src/site/pages/manual/introduction.html
index 8fef46f..4c2bc24 100644
--- a/logback-site/src/site/pages/manual/introduction.html
+++ b/logback-site/src/site/pages/manual/introduction.html
@@ -257,7 +257,7 @@ public class HelloWorld2 {
   adhere to the conditions of the LGPL license or the EPL license.
   </p>
 
-  <p>For building logback udner an IDE, please see the <a
+  <p>For building logback under an IDE, please see the <a
   href="../setup.html#ide">relevant section on the class path setup
   page</a>.</p>
   

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=ccadbcf3824fa4daf2d00411fb00f22bc0fc0672
http://github.com/ceki/logback/commit/ccadbcf3824fa4daf2d00411fb00f22bc0fc0672

commit ccadbcf3824fa4daf2d00411fb00f22bc0fc0672
Merge: be9513c 05ac03f
Author: Jörn Huxhorn <jhuxhorn at googlemail.com>
Date:   Fri Nov 4 01:17:03 2011 -0700

    Merge pull request #16 from huxi/Suppressed
    
    Adding support for Throwable.getSuppressed().


http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=05ac03fff7d519b46e1016e2790eaa1269cb1586
http://github.com/ceki/logback/commit/05ac03fff7d519b46e1016e2790eaa1269cb1586

commit 05ac03fff7d519b46e1016e2790eaa1269cb1586
Author: Joern Huxhorn <jhuxhorn at googlemail.com>
Date:   Mon Jun 13 20:20:07 2011 +0200

    Calculating packaging data for suppressed Throwables.
    
    calculate(IThrowableProxy), as expected, needs to support suppressed Throwables, too.
    
    All of this has been tested with Java 7 b145 and is working as expected.

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java
index 9e9d7b1..4693579 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java
@@ -56,6 +56,12 @@ public class PackagingDataCalculator {
   public void calculate(IThrowableProxy tp) {
     while (tp != null) {
       populateFrames(tp.getStackTraceElementProxyArray());
+      IThrowableProxy[] suppressed = tp.getSuppressed();
+      if(suppressed != null) {
+        for(IThrowableProxy current:suppressed) {
+          populateFrames(current.getStackTraceElementProxyArray());
+        }
+      }
       tp = tp.getCause();
     }
   }

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=1bb29a6050a471e7b65d97de9a73af7f8d400503
http://github.com/ceki/logback/commit/1bb29a6050a471e7b65d97de9a73af7f8d400503

commit 1bb29a6050a471e7b65d97de9a73af7f8d400503
Author: Joern Huxhorn <jhuxhorn at googlemail.com>
Date:   Sun Jun 12 16:22:04 2011 +0200

    Adding support for Throwable.getSuppressed().
    
    See http://www.oracle.com/technetwork/articles/java/trywithresources-401775.html
    
    - Removed superfluous public from methods in IThrowableProxy interface and added method IThrowableProxy[] getSuppressed().
    - Serialized ThrowableProxyVO will be incompatible since suppressed has been added. Consequently, the respective serialVersionUID has been changed.
    - ThrowableProxyVO.equals is now also checking suppressed.
    - ThrowableProxy is now evaluating suppressed Throwables of its c'tor argument if the Throwable class has a getSuppressed() method, i.e. in case of Java SE 7 and upwards.
    
    This patch is merely adding support of suppressed exceptions to the creation of LoggingEvent/IThrowableProxy. Further support should be added to the following classes:
    
    - ch.qos.logback.classic.db.DBAppender
    - ch.qos.logback.classic.html.DefaultThrowableRenderer
    - ch.qos.logback.classic.net.SyslogAppender
    - ch.qos.logback.classic.pattern.ThrowableProxyConverter
    - ch.qos.logback.classic.spi.ThrowableProxyUtil
      - method asString
    - ch.qos.logback.classic.spi.PackagingDataCalculator
      - method calculate(IThrowableProxy tp) may also need to take suppressed into account.

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java
index 03e19f1..8e841c8 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/IThrowableProxy.java
@@ -14,9 +14,10 @@
 package ch.qos.logback.classic.spi;
 
 public interface IThrowableProxy {
-  public String getMessage();
-  public String getClassName();
-  public StackTraceElementProxy[] getStackTraceElementProxyArray();
-  public int getCommonFrames();
-  public IThrowableProxy getCause();
-}
\ No newline at end of file
+  String getMessage();
+  String getClassName();
+  StackTraceElementProxy[] getStackTraceElementProxyArray();
+  int getCommonFrames();
+  IThrowableProxy getCause();
+  IThrowableProxy[] getSuppressed();
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
index 303ed6e..710e8bb 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
@@ -15,18 +15,38 @@ package ch.qos.logback.classic.spi;
 
 import ch.qos.logback.core.CoreConstants;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 public class ThrowableProxy implements IThrowableProxy {
 
-  Throwable throwable;
-  String className;
-  String message;
+  private Throwable throwable;
+  private String className;
+  private String message;
+  // package-private because of ThrowableProxyUtil
   StackTraceElementProxy[] stackTraceElementProxyArray;
+  // package-private because of ThrowableProxyUtil
   int commonFrames;
-  ThrowableProxy cause;
+  private ThrowableProxy cause;
+  private ThrowableProxy[] suppressed=NO_SUPPRESSED;
 
   private transient PackagingDataCalculator packagingDataCalculator;
   private boolean calculatedPackageData = false;
 
+  private static final Method GET_SUPPRESSED_METHOD;
+
+  static {
+    Method method = null;
+    try {
+      method = Throwable.class.getMethod("getSuppressed");
+    } catch (NoSuchMethodException e) {
+      // ignore, will get thrown in Java < 7
+    }
+    GET_SUPPRESSED_METHOD = method;
+  }
+
+  private static final ThrowableProxy[] NO_SUPPRESSED=new ThrowableProxy[0];
+
   public ThrowableProxy(Throwable throwable) {
    
     this.throwable = throwable;
@@ -43,6 +63,29 @@ public class ThrowableProxy implements IThrowableProxy {
           .findNumberOfCommonFrames(nested.getStackTrace(),
               stackTraceElementProxyArray);
     }
+    if(GET_SUPPRESSED_METHOD != null) {
+      // this will only execute on Java 7
+      try {
+        Object obj = GET_SUPPRESSED_METHOD.invoke(throwable);
+        if(obj instanceof Throwable[]) {
+          Throwable[] throwableSuppressed = (Throwable[]) obj;
+          if(throwableSuppressed.length > 0) {
+            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);
+            }
+          }
+        }
+      } catch (IllegalAccessException e) {
+        // ignore
+      } catch (InvocationTargetException e) {
+        // ignore
+      }
+    }
+
   }
 
 
@@ -80,6 +123,10 @@ public class ThrowableProxy implements IThrowableProxy {
     return cause;
   }
 
+  public IThrowableProxy[] getSuppressed() {
+    return suppressed;
+  }
+
   public PackagingDataCalculator getPackagingDataCalculator() {
     // if original instance (non-deserialized), and packagingDataCalculator
     // is not already initialized, then create an instance.
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java
index 34b7769..45b3f7d 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxyVO.java
@@ -18,13 +18,14 @@ import java.util.Arrays;
 
 public class ThrowableProxyVO implements IThrowableProxy, Serializable {
 
-  private static final long serialVersionUID = 685387990886325422L;
-  
+  private static final long serialVersionUID = -773438177285807139L;
+
   private String className;
   private String message;
   private int commonFramesCount;
   private StackTraceElementProxy[] stackTraceElementProxyArray;
   private IThrowableProxy cause;
+  private IThrowableProxy[] suppressed;
 
 
   public String getMessage() {
@@ -47,6 +48,10 @@ public class ThrowableProxyVO implements IThrowableProxy, Serializable {
     return stackTraceElementProxyArray;
   }
 
+  public IThrowableProxy[] getSuppressed() {
+    return suppressed;
+  }
+
   @Override
   public int hashCode() {
     final int prime = 31;
@@ -75,6 +80,9 @@ public class ThrowableProxyVO implements IThrowableProxy, Serializable {
     if (!Arrays.equals(stackTraceElementProxyArray, other.stackTraceElementProxyArray))
       return false;
     
+    if (!Arrays.equals(suppressed, other.suppressed))
+      return false;
+
     if (cause == null) {
       if (other.cause != null)
         return false;
@@ -93,8 +101,16 @@ public class ThrowableProxyVO implements IThrowableProxy, Serializable {
     tpvo.message = throwableProxy.getMessage();
     tpvo.commonFramesCount = throwableProxy.getCommonFrames();
     tpvo.stackTraceElementProxyArray = throwableProxy.getStackTraceElementProxyArray();
-    if(throwableProxy.getCause() != null) {
-      tpvo.cause = ThrowableProxyVO.build(throwableProxy.getCause());
+    IThrowableProxy cause = throwableProxy.getCause();
+    if(cause != null) {
+      tpvo.cause = ThrowableProxyVO.build(cause);
+    }
+    IThrowableProxy[] suppressed = throwableProxy.getSuppressed();
+    if(suppressed != null) {
+      tpvo.suppressed = new IThrowableProxy[suppressed.length];
+      for(int i = 0;i<suppressed.length;i++) {
+        tpvo.suppressed[i] = ThrowableProxyVO.build(suppressed[i]);
+      }
     }
     return tpvo;
   }
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java
index c7231ea..b6e48bd 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/DummyThrowableProxy.java
@@ -20,7 +20,7 @@ public class DummyThrowableProxy implements IThrowableProxy {
   private int commonFramesCount;
   private StackTraceElementProxy[] stackTraceElementProxyArray;
   private IThrowableProxy cause;
-  
+  private IThrowableProxy[] suppressed;
 
   public String getClassName() {
     return className;
@@ -54,8 +54,12 @@ public class DummyThrowableProxy implements IThrowableProxy {
   public void setCause(IThrowableProxy cause) {
     this.cause = cause;
   }
-  
-  
 
+  public IThrowableProxy[] getSuppressed() {
+    return suppressed;
+  }
 
+  public void setSuppressed(IThrowableProxy[] suppressed) {
+    this.suppressed = suppressed;
+  }
 }

-----------------------------------------------------------------------

Summary of changes:
 .../qos/logback/classic/spi/IThrowableProxy.java   |   13 +++--
 .../classic/spi/PackagingDataCalculator.java       |    6 ++
 .../ch/qos/logback/classic/spi/ThrowableProxy.java |   55 ++++++++++++++++++--
 .../qos/logback/classic/spi/ThrowableProxyVO.java  |   24 +++++++--
 .../logback/classic/spi/DummyThrowableProxy.java   |   10 +++-
 .../src/site/pages/manual/introduction.html        |    2 +-
 6 files changed, 92 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list