You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/11/17 06:21:04 UTC
svn commit: r1203052 -
/tomcat/trunk/java/org/apache/tomcat/util/buf/UDecoder.java
Author: kkolinko
Date: Thu Nov 17 05:21:04 2011
New Revision: 1203052
URL: http://svn.apache.org/viewvc?rev=1203052&view=rev
Log:
Reduce overhead from exception handling, using ProxyDirContext.NOT_FOUND_EXCEPTION as an example.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/buf/UDecoder.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/UDecoder.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/UDecoder.java?rev=1203052&r1=1203051&r2=1203052&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/UDecoder.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/UDecoder.java Thu Nov 17 05:21:04 2011
@@ -32,6 +32,30 @@ public final class UDecoder {
protected static final boolean ALLOW_ENCODED_SLASH =
Boolean.valueOf(System.getProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "false")).booleanValue();
+ private static class DecodeException extends CharConversionException {
+ private static final long serialVersionUID = 1L;
+ public DecodeException(String s) {
+ super(s);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ // This class does not provide a stack trace
+ return this;
+ }
+ }
+
+ /** Unexpected end of data. */
+ private static final IOException EXCEPTION_EOF = new DecodeException("EOF");
+
+ /** %xx with not-hex digit */
+ private static final IOException EXCEPTION_NOT_HEX_DIGIT = new DecodeException(
+ "isHexDigit");
+
+ /** %-encoded slash is forbidden in resource path */
+ private static final IOException EXCEPTION_SLASH = new DecodeException(
+ "noSlash");
+
public UDecoder()
{
}
@@ -78,18 +102,18 @@ public final class UDecoder {
} else {
// read next 2 digits
if( j+2 >= end ) {
- throw new CharConversionException("EOF");
+ throw EXCEPTION_EOF;
}
byte b1= buff[j+1];
byte b2=buff[j+2];
if( !isHexDigit( b1 ) || ! isHexDigit(b2 )) {
- throw new CharConversionException( "isHexDigit");
+ throw EXCEPTION_NOT_HEX_DIGIT;
}
j+=2;
int res=x2c( b1, b2 );
if (noSlash && (res == '/')) {
- throw new CharConversionException( "noSlash");
+ throw EXCEPTION_SLASH;
}
buff[idx]=(byte)res;
}
@@ -144,12 +168,12 @@ public final class UDecoder {
// read next 2 digits
if( j+2 >= cend ) {
// invalid
- throw new CharConversionException("EOF");
+ throw EXCEPTION_EOF;
}
char b1= buff[j+1];
char b2=buff[j+2];
if( !isHexDigit( b1 ) || ! isHexDigit(b2 )) {
- throw new CharConversionException("isHexDigit");
+ throw EXCEPTION_NOT_HEX_DIGIT;
}
j+=2;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org