Provide accurate InputStream.available() results
Provide accurate InputStream.available() results by using the size attribute of the ZipEntry. This helps improve performance with CGLib and also fixes issues where libraries expect that a non-zero result from available() indicates that read() will not return -1.
This commit is contained in:
@@ -115,7 +115,9 @@ public class RandomAccessJarFileTests {
|
||||
public void getInputStream() throws Exception {
|
||||
InputStream inputStream = this.jarFile.getInputStream(this.jarFile
|
||||
.getEntry("1.dat"));
|
||||
assertThat(inputStream.available(), equalTo(1));
|
||||
assertThat(inputStream.read(), equalTo(1));
|
||||
assertThat(inputStream.available(), equalTo(0));
|
||||
assertThat(inputStream.read(), equalTo(-1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user