You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Jeremy Boynes <jb...@gluecode.com> on 2004/09/27 21:48:31 UTC

Re: svn commit: rev 47326 - in geronimo/trunk/modules: common/src/java/org/apache/geronimo/common deployment/src/java/org/apache/geronimo/deployment

I am voting -1 on this change due to
1) the loss of information from the stack trace. To the people who
    need to see one, then they should see all the information; cutting
    out levels to simplify the display to end users is not a solution
    to giving them proper diagnostic information.

2) the dependency on elimination of specific packages e.g. mx4j that
    may not be relevant (e.g. if native Java5 JMX is used instead)

3) that the number of levels in the stack may be relevant (e.g. for
    security checks that look at the stack) and this obfuscates that
    information

4) the same functionality can be implemented in whatever decides to
    print/log the stacktrace rather than in the Exception itself

--
Jeremy

dblevins@apache.org wrote:
> Author: dblevins
> Date: Mon Sep 27 12:33:39 2004
> New Revision: 47326
> 
> Added:
>    geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java
> Modified:
>    geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java
> Log:
> New util to cut out parts of a stacktrace which are "glue" level.  Not
> perfect, but a step in the right direction.  
> 
> Cuts out o.a.g.gbean.jmx.*, mx4j.*, and net.sf.cglib.reflect.*
> 
> Put it in action on the DeploymentException.
> 
> 
> 
> Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java
> ==============================================================================
> --- (empty file)
> +++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java	Mon Sep 27 12:33:39 2004
> @@ -0,0 +1,51 @@
> +/**
> + *
> + * Copyright 2003-2004 The Apache Software Foundation
> + *
> + *  Licensed under the Apache License, Version 2.0 (the "License");
> + *  you may not use this file except in compliance with the License.
> + *  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +package org.apache.geronimo.deployment;
> +
> +import java.util.ArrayList;
> +
> +/**
> + * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
> + */
> +public class ExceptionUtil {
> +
> +    private static final String[] excludedPackages = {
> +        "org.apache.geronimo.gbean.jmx.", "mx4j.", "net.sf.cglib.reflect"
> +    };
> +
> +    public static void trimStackTrace(Throwable t) {
> +        if (t == null) {
> +            return;
> +        }
> +
> +        StackTraceElement[] trace = t.getStackTrace();
> +        ArrayList list = new ArrayList();
> +
> +        TRIM: for (int i = 0; i < trace.length; i++) {
> +            String className = trace[i].getClassName();
> +            for (int j = 0; j < excludedPackages.length; j++) {
> +                if (className.startsWith(excludedPackages[j])) {
> +                    continue TRIM;
> +                }
> +            }
> +            list.add(trace[i]);
> +        }
> +
> +        t.setStackTrace((StackTraceElement[]) list.toArray(new StackTraceElement[0]));
> +        trimStackTrace(t.getCause());
> +    }
> +}
> 
> Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java
> ==============================================================================
> --- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java	(original)
> +++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java	Mon Sep 27 12:33:39 2004
> @@ -17,27 +17,32 @@
>  
>  package org.apache.geronimo.deployment;
>  
> +
> +
> +
>  /**
> - *
> - *
>   * @version $Rev$ $Date$
>   */
>  public class DeploymentException extends Exception {
>  
>  
>      public DeploymentException() {
> +        ExceptionUtil.trimStackTrace(this);
>      }
>  
>      public DeploymentException(Throwable cause) {
>          super(cause);
> +        ExceptionUtil.trimStackTrace(this);
>      }
>  
>      public DeploymentException(String message) {
>          super(message);
> +        ExceptionUtil.trimStackTrace(this);
>      }
>  
>      public DeploymentException(String message, Throwable cause) {
>          super(message, cause);
> +        ExceptionUtil.trimStackTrace(this);
>      }
>  
>  }


Re: svn commit: rev 47326 - in geronimo/trunk/modules: common/src/java/org/apache/geronimo/common deployment/src/java/org/apache/geronimo/deployment

Posted by David Blevins <da...@visi.com>.
As the commit messages says, still working on it.  Great minds think
alike as i've already done number 4.  Commit coming soon.

-David

On Mon, Sep 27, 2004 at 12:48:31PM -0700, Jeremy Boynes wrote:
> I am voting -1 on this change due to
> 1) the loss of information from the stack trace. To the people who
>    need to see one, then they should see all the information; cutting
>    out levels to simplify the display to end users is not a solution
>    to giving them proper diagnostic information.
> 
> 2) the dependency on elimination of specific packages e.g. mx4j that
>    may not be relevant (e.g. if native Java5 JMX is used instead)
> 
> 3) that the number of levels in the stack may be relevant (e.g. for
>    security checks that look at the stack) and this obfuscates that
>    information
> 
> 4) the same functionality can be implemented in whatever decides to
>    print/log the stacktrace rather than in the Exception itself
> 
> --
> Jeremy
> 
> dblevins@apache.org wrote:
> >Author: dblevins
> >Date: Mon Sep 27 12:33:39 2004
> >New Revision: 47326
> >
> >Added:
> >   geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java
> >Modified:
> >   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java
> >Log:
> >New util to cut out parts of a stacktrace which are "glue" level.  Not
> >perfect, but a step in the right direction.  
> >
> >Cuts out o.a.g.gbean.jmx.*, mx4j.*, and net.sf.cglib.reflect.*
> >
> >Put it in action on the DeploymentException.
> >
> >
> >
> >Added: 
> >geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java
> >==============================================================================
> >--- (empty file)
> >+++ 
> >geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/ExceptionUtil.java	Mon Sep 27 12:33:39 2004
> >@@ -0,0 +1,51 @@
> >+/**
> >+ *
> >+ * Copyright 2003-2004 The Apache Software Foundation
> >+ *
> >+ *  Licensed under the Apache License, Version 2.0 (the "License");
> >+ *  you may not use this file except in compliance with the License.
> >+ *  You may obtain a copy of the License at
> >+ *
> >+ *     http://www.apache.org/licenses/LICENSE-2.0
> >+ *
> >+ *  Unless required by applicable law or agreed to in writing, software
> >+ *  distributed under the License is distributed on an "AS IS" BASIS,
> >+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> >implied.
> >+ *  See the License for the specific language governing permissions and
> >+ *  limitations under the License.
> >+ */
> >+package org.apache.geronimo.deployment;
> >+
> >+import java.util.ArrayList;
> >+
> >+/**
> >+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 
> >2004) $
> >+ */
> >+public class ExceptionUtil {
> >+
> >+    private static final String[] excludedPackages = {
> >+        "org.apache.geronimo.gbean.jmx.", "mx4j.", "net.sf.cglib.reflect"
> >+    };
> >+
> >+    public static void trimStackTrace(Throwable t) {
> >+        if (t == null) {
> >+            return;
> >+        }
> >+
> >+        StackTraceElement[] trace = t.getStackTrace();
> >+        ArrayList list = new ArrayList();
> >+
> >+        TRIM: for (int i = 0; i < trace.length; i++) {
> >+            String className = trace[i].getClassName();
> >+            for (int j = 0; j < excludedPackages.length; j++) {
> >+                if (className.startsWith(excludedPackages[j])) {
> >+                    continue TRIM;
> >+                }
> >+            }
> >+            list.add(trace[i]);
> >+        }
> >+
> >+        t.setStackTrace((StackTraceElement[]) list.toArray(new 
> >StackTraceElement[0]));
> >+        trimStackTrace(t.getCause());
> >+    }
> >+}
> >
> >Modified: 
> >geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java
> >==============================================================================
> >--- 
> >geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java	(original)
> >+++ 
> >geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentException.java	Mon Sep 27 12:33:39 2004
> >@@ -17,27 +17,32 @@
> > 
> > package org.apache.geronimo.deployment;
> > 
> >+
> >+
> >+
> > /**
> >- *
> >- *
> >  * @version $Rev$ $Date$
> >  */
> > public class DeploymentException extends Exception {
> > 
> > 
> >     public DeploymentException() {
> >+        ExceptionUtil.trimStackTrace(this);
> >     }
> > 
> >     public DeploymentException(Throwable cause) {
> >         super(cause);
> >+        ExceptionUtil.trimStackTrace(this);
> >     }
> > 
> >     public DeploymentException(String message) {
> >         super(message);
> >+        ExceptionUtil.trimStackTrace(this);
> >     }
> > 
> >     public DeploymentException(String message, Throwable cause) {
> >         super(message, cause);
> >+        ExceptionUtil.trimStackTrace(this);
> >     }
> > 
> > }