Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.12.0, 2.13.0
-
None
Description
I have several test cases that check that my SAX parsers correctly handle empty files. Since the upgrade of commons-io from 2.11.0 to 2.12.0 these tests fail with the following exception:
java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END at java.base/java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:996) at java.base/java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:578) at org.apache.commons.io.input.ReaderInputStream.fillBuffer(ReaderInputStream.java:357) at org.apache.commons.io.input.ReaderInputStream.read(ReaderInputStream.java:388) at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.readAndBuffer(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at edu.hm.hafner.analysis.parser.ReaderTest.shouldThrowIoException(ReaderTest.java:24)
From my understanding the method ReaderInputStream.fillBuffer should silently handle empty streams (or throw an IOException).
Here is a PR with a test case that exposes the bug: https://github.com/jenkinsci/analysis-model/pull/923/files
Here is the associated failure in our CI:
https://ci.jenkins.io/job/Plugins/job/analysis-model/job/PR-923/4/testReport/junit/edu.hm.hafner.analysis.parser/ReaderTest/linux_17___Build__linux_17____shouldThrowIoException/