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