tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tino Schwarze <tino.schwa...@tisc.de>
Subject Re: svn commit: r365858 - /tomcat/sandbox/java/org/apache/tomcat/util/buf/ByteChunk.java
Date Wed, 04 Jan 2006 10:55:15 GMT
On Wed, Jan 04, 2006 at 07:48:43AM -0000, costin@apache.org wrote:

> Modified: tomcat/sandbox/java/org/apache/tomcat/util/buf/ByteChunk.java
> URL: http://svn.apache.org/viewcvs/tomcat/sandbox/java/org/apache/tomcat/util/buf/ByteChunk.java?rev=365858&r1=365857&r2=365858&view=diff
> ==============================================================================
> --- tomcat/sandbox/java/org/apache/tomcat/util/buf/ByteChunk.java (original)
> +++ tomcat/sandbox/java/org/apache/tomcat/util/buf/ByteChunk.java Tue Jan  3 23:48:42
2006
> @@ -690,15 +690,19 @@
>              int myPos=i+1;
>  
>              // not enough chars to have a match
> -            if( i + srcLen >= end ) {
> +            if( myPos + srcLen >= end ) {
>                  break;
>              }
>              
> +            try {
>  	    for( int srcPos=srcOff + 1; srcPos< srcEnd; ) {
>                  if( bb.get(myPos++) != src.charAt( srcPos++ ))
>  		    break;
>                  if( srcPos==srcEnd ) return i-start; // found it
>  	    }
> +            } catch( Throwable t ) {
> +                t.printStackTrace();
> +            }

Argh! Never ever do that!
1) don't catch Throwable - you'll happily consume OutOfMemoryError and
   similar bad things here which should certainly be passed along.
2) don't use printStackTrace() - use a suitable logger instead

Just my 2 cents,

Tino.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message