Catching an exception and throwing the original away means that you have
lost the call stack.  You should either log it, or wrap the entire stack
trace into the new exception.  While writing the stack trace to standard
output may not be what you really want (does SOAP have a log file?), you
have introduced a more serious problem: you have no way to determine the
root cause of the original exception in the code introduced below.

When you wrap one exception into another, the value of printing/logging the
stack trace can be debated since you are propogating the original to the
final "catch".


<ras>

*******************************************
Richard A. Sitze



                                                                                       
                      
                      [EMAIL PROTECTED]                                                 
                      
                      rg                       To:      [EMAIL PROTECTED]        
                      
                                               cc:                                     
                      
                      05/02/2002 01:43         Subject: cvs commit:                    
                      
                      PM                       
xml-soap/java/src/org/apache/soap/server/http                 
                      Please respond           MessageRouterServlet.java 
RPCRouterServlet.java               
                      to soap-dev                                                      
                      
                                                                                       
                      
                                                                                       
                      




duftler     02/05/02 11:43:30

  Modified:    java/src/org/apache/soap/server/http
                        MessageRouterServlet.java RPCRouterServlet.java
  Log:
  Removed 2 server-side stack traces where exceptions were also being
    propagated. For more info, see:
    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4166
  Submitted by:          [EMAIL PROTECTED]
  Reviewed by:           Matthew J. Duftler ([EMAIL PROTECTED])

  Revision  Changes    Path
  1.30      +0 -2
xml-soap/java/src/org/apache/soap/server/http/MessageRouterServlet.java

  Index: MessageRouterServlet.java
  ===================================================================
  RCS file:
/home/cvs/xml-soap/java/src/org/apache/soap/server/http/MessageRouterServlet.java,v

  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- MessageRouterServlet.java            9 Jul 2001 23:24:37 -0000
 1.29
  +++ MessageRouterServlet.java            2 May 2002 18:43:30 -0000
 1.30
  @@ -331,10 +331,8 @@
         OutputStream outStream = res.getOutputStream();
         sres.writeTo(outStream);
       }
  -    // NOTE: fix this to return server-side SOAP exceptions instead.
       catch (Exception e)
       {
  -        e.printStackTrace();
           throw new ServletException ("Error building response envelope: "
+ e);
       }
     }



  1.34      +0 -2
xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java

  Index: RPCRouterServlet.java
  ===================================================================
  RCS file:
/home/cvs/xml-soap/java/src/org/apache/soap/server/http/RPCRouterServlet.java,v

  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- RPCRouterServlet.java          9 Jul 2001 23:24:38 -0000
1.33
  +++ RPCRouterServlet.java          2 May 2002 18:43:30 -0000
1.34
  @@ -347,10 +347,8 @@
         OutputStream outStream = res.getOutputStream();
         sres.writeTo(outStream);
       }
  -    // NOTE: fix this to return server-side SOAP exceptions instead.
       catch (Exception e)
       {
  -        e.printStackTrace();
           throw new ServletException ("Error building response envelope: "
+ e);
       }
     }






Reply via email to