Dear All,

> One obvious solution, Mr Gladwell, is to use the version of
> Tomcat that works.  Is there something
> that makes it necessary to use the milestone build instead of the
> release?  If your project is
<snip>

Unfortunately, I really must use the Tomcat milestone build: it is the
latest 3.3 milestone that will allow JDBCRealms authentication through IIS,
which I need for securing my JSP pages. I realise that this is a compromise
for a production project but, considering the JDBCRealms problem, I don't
really consider 3.2.1 as ready for production either.

In the end, it matters not: I managed to resolve the error. The
implementation of BodyContentImpl.write()is not properly checking the bounds
of its buffer and runs out of buffer space. The JSP code that throws the
ArrayOutOfBoundsException is in the middle of a Taglibs body tag. A large
amount of data is pulled and is buffered, which causes the buffer to
overflow.

By increasing the size of the BodyContentImpl class buffer (by four times
it's original size) the problem is resolved. The fact that buffer is allowed
to overflow remains a problem. I shall be submitting the bug to the Jakarta
bug database and I am writing this as a reference for anyone encountering
similar problems.

Yours...

--
Ricardo Gladwell
UBQT Media PLC, Windsor
Mobile: (07779) 841 444

> -----Original Message-----
> From: Brian Murray [mailto:[EMAIL PROTECTED]]
> Sent: 02 May 2001 12:39
> To: [EMAIL PROTECTED]
> Subject: Re: Bad ArrayOutOfBoundsException in BodyContentImpl.write()
>
>
> > I am using the milestone build Tomcat 3.33 M2 on Windows 2000
> through IIS.
> > At the moment certain pages are throwing a very strange
> > "ArrayIndexOutOfBoundsException" (see stack trace below). The pages use
> > valid index.jsp (and succussfully run on Tomcat 3.2.1). The error occurs
> > within text output that:
> <snip>
>
> One obvious solution, Mr Gladwell, is to use the version of
> Tomcat that works.  Is there something
> that makes it necessary to use the milestone build instead of the
> release?  If your project is
> 'urgent' in the sense that others are waiting for you to deliver
> it then perhaps it would be more
> prudent to use the build that's 'ready for Prime Time.'
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
>
--- BodyContentImpl.java.orig   Wed May  2 11:36:36 2001
+++ BodyContentImpl.java        Wed May  2 11:34:34 2001
@@ -103,9 +103,6 @@
         }
     }
 
-    /** Make space for len chars. If len is small, allocate
-       a reserve space too.
-     */
     private void reAllocBuff (int len) {
         //Need to re-allocate the buffer since it is to be
        //unbounded according to the updated spec..
@@ -114,12 +111,13 @@
 
        //XXX Should it be multiple of DEFAULT_BUFFER_SIZE??
 
-       if (len <= Constants.DEFAULT_BUFFER_SIZE) {
-           bufferSize = bufferSize * 2;
+    int newBufferSize = bufferSize * 4;
+    if (len <= newBufferSize) {
+           bufferSize = newBufferSize;
            tmp = new char [bufferSize];
        } else {
+           tmp = new char [bufferSize + len];
            bufferSize += len;
-           tmp = new char [bufferSize];
        }
        System.arraycopy(cb, 0, tmp, 0, cb.length);
        cb = tmp;
@@ -182,8 +180,6 @@
            if (len >= bufferSize - nextChar)
                reAllocBuff(len);
 
-           //System.out.println("XXX " + off + " " + (off+len) + " " +
-           // nextChar + " " + bufferSize + " "+  cb.length);
             s.getChars(off, off + len, cb, nextChar);
            nextChar += len;
         }

Reply via email to