marcsaeg 2003/07/01 13:59:58 Modified: src/share/org/apache/tomcat/core Tag: tomcat_32 ContextManager.java Log: Check for debug > 0 before printing debug messages. Catch SocketException to avoid sending data down a closed connection. Revision Changes Path No revision No revision 1.100.2.28 +17 -9 jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java Index: ContextManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v retrieving revision 1.100.2.27 retrieving revision 1.100.2.28 diff -u -r1.100.2.27 -r1.100.2.28 --- ContextManager.java 5 Oct 2001 18:12:33 -0000 1.100.2.27 +++ ContextManager.java 1 Jul 2003 20:59:57 -0000 1.100.2.28 @@ -567,7 +567,8 @@ } String vhost=ctx.getHost(); - logInt("Adding context " + ctx.toString()); + if(debug>0) + logInt("Adding context " + ctx.toString()); // XXX temporary workaround for the old SimpleMapper - // This code will be removed as soon as the new mapper is stable. @@ -581,7 +582,8 @@ public void removeContext( Context context ) throws TomcatException { if( context==null ) return; - logInt( "Removing context " + context.toString()); + if(debug>0) + logInt( "Removing context " + context.toString()); ContextInterceptor cI[]=getContextInterceptors(); for( int i=0; i< cI.length; i++ ) { @@ -1038,8 +1040,8 @@ // XXX this log was intended to debug the status code generation. // it can be removed for all cases. if( code != 302 && code != 401 ) - ctx.log( code + " " + req + " " + - req.getAttribute("javax.servlet.error.message")); + if(debug>0) + ctx.log( code + " " + req + " " + req.getAttribute("javax.servlet.error.message")); errorPath = ctx.getErrorPage( code ); if( errorPath != null ) { @@ -1098,7 +1100,14 @@ Note that it is _WRONG_ to send the trace back to the client. AFAIK the trace is the _best_ debugger. */ - if (t instanceof UnavailableException) { + if( t instanceof SocketException ) { + /* + * There's nothing we can do in this case because the connection + * with the client is already gone. MAS 1/14/03 + */ + ctx.log("SocketException in: " + req + " " + t.getMessage()); + return; + }else if (t instanceof UnavailableException) { int unavailableTime = -1; if ( !((UnavailableException)t).isPermanent() ) { unavailableTime = ((UnavailableException)t).getUnavailableSeconds(); @@ -1115,16 +1124,15 @@ res.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); // 503 handleStatus( req, res, HttpServletResponse.SC_SERVICE_UNAVAILABLE ); return; - } - else if( t instanceof IllegalStateException ) { + } else if( t instanceof IllegalStateException ) { ctx.log("IllegalStateException in: " + req + " " + t.getMessage() ); } else if( t instanceof org.apache.jasper.JasperException ) { ctx.log("JasperException: " + req + " " + t.getMessage()); } else if( t instanceof IOException ) { if ( "Broken pipe".equals(t.getMessage())) - return; - ctx.log("IOException in: " + req + " " + t.getMessage()); + return; + ctx.log("IOException in: " + req + " " + t.getMessage()); } else { ctx.log("Exception in: " + req , t ); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]