Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 77483 invoked from network); 23 Apr 2002 19:55:12 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 23 Apr 2002 19:55:12 -0000 Received: (qmail 23286 invoked by uid 97); 23 Apr 2002 19:55:08 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 23270 invoked by uid 97); 23 Apr 2002 19:55:08 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 23244 invoked from network); 23 Apr 2002 19:55:07 -0000 Message-ID: From: "Schreibman, David" To: "'Tomcat Developers List'" Subject: RE: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/to mcat/util/buf ByteChunk.java Date: Tue, 23 Apr 2002 13:02:10 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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: keith@apache.org [mailto:keith@apache.org] Sent: Tuesday, April 23, 2002 12:44 PM To: jakarta-tomcat-connectors-cvs@apache.org 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: For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: