commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhang, Huxing" <huxing.zh...@intel.com>
Subject [io] missing java.io.PrintWriter.close() in org.apache.commons.io.testtools.FileBasedTestCase.checkWrite()
Date Mon, 25 Oct 2010 02:47:58 GMT
Dear Apache Commons IO developers,
I found there might be a close method missing in the source code of test cases, which may
be an issue.
No patch seems to be applied till revision 1026932.
How do you guys think?

The original code here is:
In io/trunk/src/test/java/org/apache/commons/io/testtools/FileBasedTestCase.java
Line 203-223 (revision 1026932)

protected void checkWrite(OutputStream output) throws Exception {
        try {
            new java.io.PrintStream(output).write(0);
        } catch (Throwable t) {
            throw new AssertionFailedError(
                "The copy() method closed the stream "
                    + "when it shouldn't have. "
                    + t.getMessage());
        }
    }

    protected void checkWrite(Writer output) throws Exception {
        try {
            new java.io.PrintWriter(output).write('a');
        } catch (Throwable t) {
            throw new AssertionFailedError(
                "The copy() method closed the stream "
                    + "when it shouldn't have. "
                    + t.getMessage());
        }
    }

The java.io.PrintWriter is initialized without being closed after use. So does the java.io.PrintStream
instance.

Thanks &Best regards,
Huxing


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message