With crap4j ant task v 1.1.6. The test runner will eventually fail after
processing a certain number of files since CPStringReader.readClass()
doesn't close the inputstream
Wrapping the method in a try/finally seems to have solved the problem.
private static byte[] readClass(final InputStream is) throws IOException {
try {
if (is == null) {
throw new IOException("Class not found");
}
byte[] b = new byte[is.available()];
int len = 0;
while (true) {
int n = is.read(b, len, b.length - len);
if (n == -1) {
if (len < b.length) {
byte[] c = new byte[len];
System.arraycopy(b, 0, c, 0, len);
b = c;
}
return b;
}
len += n;
if (len == b.length) {
byte[] c = new byte[b.length + 1000];
System.arraycopy(b, 0, c, 0, len);
b = c;
}
}
} finally {
try {
is.close();
} catch (IOException e) {
}
}
}
Original issue reported on code.google.com by case.nel...@gmail.com on 25 May 2009 at 8:06
Original issue reported on code.google.com by
case.nel...@gmail.com
on 25 May 2009 at 8:06