In the following code, I think that if b2 is actually null, you'll get an
NPE for b2.length. Better to check whether (b2 == null) first. Right?
+ if (b2.length > len || b1 == null || b2 == null) {
+ return false;
-David
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 12:44 PM
To: [EMAIL PROTECTED]
Subject: cvs commit:
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf
ByteChunk.java
keith 02/04/23 12:44:14
Modified: util/java/org/apache/tomcat/util/buf ByteChunk.java
Log:
Add startsWith(byte[]) for use by DecoderInterceptor
Revision Changes Path
1.10 +18 -0
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.jav
a
Index: ByteChunk.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Byt
eChunk.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ByteChunk.java 16 Mar 2002 06:37:46 -0000 1.9
+++ ByteChunk.java 23 Apr 2002 19:44:14 -0000 1.10
@@ -549,6 +549,24 @@
return true;
}
+ /* Returns true if the message bytes start with the specified byte
array */
+ public boolean startsWith(byte[] b2) {
+ byte[] b1 = buff;
+ if (b1 == null && b2 == null) {
+ return true;
+ }
+
+ int len = end - start;
+ if (b2.length > len || b1 == null || b2 == null) {
+ return false;
+ }
+ for (int i = start, j = 0; i < end && j < b2.length; ) {
+ if (b1[i++] != b2[j++])
+ return false;
+ }
+ return true;
+ }
+
/**
* Returns true if the message bytes starts with the specified
string.
* @param s the string
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>