You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by "George T. Joseph" <gt...@peakin.com> on 2000/03/25 03:33:00 UTC

Patch for ChunkyByteArray.java (3rd try)

This patch seems to keep getting lost.  Could someone at least create a bug
report for the problem?

Problem:  ChunkyByteArray doesn't implement InputStream.close().  Other methods
that call ChunkyByteArray.close() as they should, are actually invoking
InputStream.close() which itself is a noop.  ChunkyByteArray does set the field
holding the encapsulated InputStream to null but it won't be forced closed until
its finalizer is actually run.  In a long running JVM with a large heap, that
might be a while, or never.


--- l:/src/org/apache/xerces/utils/ChunkyByteArray.java	Tue Jan 25 19:26:43 2000
+++ x:/src/org/apache/xerces/utils/ChunkyByteArray.java	Thu Feb 24 11:24:10 2000
@@ -109,8 +109,6 @@
         int b = (int)(fData[0][fOffset]);
         if (++fOffset == fLength) {
             fData = null;
-            if (fLength < CHUNK_SIZE)
-                fInputStream = null;
         }
         return b;
     }
@@ -134,8 +132,6 @@
         byte[] chunk = fData[0];
         if (length >= bytesLeft) {
             length = bytesLeft;
-            if (fLength < CHUNK_SIZE)
-                fInputStream = null;
         }
         if (buffer == null) {
             fOffset += length;
@@ -209,8 +205,6 @@
             result = fInputStream.read(data, offset, capacity);
             if (result == -1) {
                 data[offset] = (byte)0xff;
-                fInputStream.close();
-                fInputStream = null;
                 break;
             }
             if (result > 0) {
@@ -219,6 +213,12 @@
                 capacity -= result;
             }
         } while (capacity > 0);
+    }
+    public void close() throws IOException
+    {
+       if (fInputStream == null) return;
+       fInputStream.close();
+       fInputStream=null;
     }
     //
     // Chunk size constants


Re: Patch for ChunkyByteArray.java (3rd try)

Posted by Pierpaolo Fumagalli <pi...@apache.org>.
Mike Pogue wrote:
> 
> Everybody can create bug reports now!  http://xml.apache.org/bugs is
> the place to do it...
> Registration is free and quick!

What happended to the 20$/bug support fee? Are you all nuts? :) :) :)

	Pier

-- 
----------------------------------------------------------------------
pier: stable structure erected over water to allow docking of seacraft
<ma...@betaversion.org>      <http://www.betaversion.org/~pier/>
----------------------------------------------------------------------


Re: Patch for ChunkyByteArray.java (3rd try)

Posted by Mike Pogue <mp...@apache.org>.
Everybody can create bug reports now!  http://xml.apache.org/bugs is the place to do it...
Registration is free and quick!

Thanks much!!
Mike

"George T. Joseph" wrote:
> 
> This patch seems to keep getting lost.  Could someone at least create a bug
> report for the problem?
> 
> Problem:  ChunkyByteArray doesn't implement InputStream.close().  Other methods
> that call ChunkyByteArray.close() as they should, are actually invoking
> InputStream.close() which itself is a noop.  ChunkyByteArray does set the field
> holding the encapsulated InputStream to null but it won't be forced closed until
> its finalizer is actually run.  In a long running JVM with a large heap, that
> might be a while, or never.
> 
> --- l:/src/org/apache/xerces/utils/ChunkyByteArray.java Tue Jan 25 19:26:43 2000
> +++ x:/src/org/apache/xerces/utils/ChunkyByteArray.java Thu Feb 24 11:24:10 2000
> @@ -109,8 +109,6 @@
>          int b = (int)(fData[0][fOffset]);
>          if (++fOffset == fLength) {
>              fData = null;
> -            if (fLength < CHUNK_SIZE)
> -                fInputStream = null;
>          }
>          return b;
>      }
> @@ -134,8 +132,6 @@
>          byte[] chunk = fData[0];
>          if (length >= bytesLeft) {
>              length = bytesLeft;
> -            if (fLength < CHUNK_SIZE)
> -                fInputStream = null;
>          }
>          if (buffer == null) {
>              fOffset += length;
> @@ -209,8 +205,6 @@
>              result = fInputStream.read(data, offset, capacity);
>              if (result == -1) {
>                  data[offset] = (byte)0xff;
> -                fInputStream.close();
> -                fInputStream = null;
>                  break;
>              }
>              if (result > 0) {
> @@ -219,6 +213,12 @@
>                  capacity -= result;
>              }
>          } while (capacity > 0);
> +    }
> +    public void close() throws IOException
> +    {
> +       if (fInputStream == null) return;
> +       fInputStream.close();
> +       fInputStream=null;
>      }
>      //
>      // Chunk size constants