Under 2 of 3 EOF conditions, the InputStream under ChunkyByteArray was not being
closed before fInputStream was set to null. This resulted in files being left
open even after all parsing was complete. Usually the JVM cleans this up when
the InputStream is garbage collected. However, if the GC doesn't run (either
because a large heap is allocated or because it's turned off) the files remain
locked.
george
*** xml-xerces/java/src/org/apache/xerces/utils/ChunkyByteArray.java Tue Jan
25
19:26:44 2000
--- src/org/apache/xerces/utils/ChunkyByteArray.java Mon Feb 07 02:07:16 2000
***************
*** 109,116 ****
int b = (int)(fData[0][fOffset]);
if (++fOffset == fLength) {
fData = null;
! if (fLength < CHUNK_SIZE)
! fInputStream = null;
}
return b;
}
--- 109,115 ----
int b = (int)(fData[0][fOffset]);
if (++fOffset == fLength) {
fData = null;
! if (fLength < CHUNK_SIZE) close();
}
return b;
}
***************
*** 134,141 ****
byte[] chunk = fData[0];
if (length >= bytesLeft) {
length = bytesLeft;
! if (fLength < CHUNK_SIZE)
! fInputStream = null;
}
if (buffer == null) {
fOffset += length;
--- 133,139 ----
byte[] chunk = fData[0];
if (length >= bytesLeft) {
length = bytesLeft;
! if (fLength < CHUNK_SIZE)close();
}
if (buffer == null) {
fOffset += length;
***************
*** 209,216 ****
result = fInputStream.read(data, offset, capacity);
if (result == -1) {
data[offset] = (byte)0xff;
! fInputStream.close();
! fInputStream = null;
break;
}
if (result > 0) {
--- 207,213 ----
result = fInputStream.read(data, offset, capacity);
if (result == -1) {
data[offset] = (byte)0xff;
! close();
break;
}
if (result > 0) {
***************
*** 220,225 ****
--- 217,230 ----
}
} while (capacity > 0);
}
+ public void close() throws IOException
+ {
+ if (fInputStream != null)
+ {
+ fInputStream.close();
+ fInputStream=null;
+ }
+ }
//
// Chunk size constants
//