< prev index next >
test/jdk/java/util/jar/JarFile/SignedJarFileGetInputStream.java
Print this page
8206863: A closed JarVerifier.VerifierStream should throw IOException
Reviewed-by: rasbold
Contributed-by: Tobias Thierer <tobiast@google.com>, Martin Buchholz <martinrb@google.com>
*** 20,30 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
! * @bug 4845692
* @summary JarFile.getInputStream should not throw when jar file is signed
* @author Martin Buchholz
*/
import java.io.*;
--- 20,30 ----
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
! * @bug 4845692 8206863
* @summary JarFile.getInputStream should not throw when jar file is signed
* @author Martin Buchholz
*/
import java.io.*;
*** 40,46 ****
--- 40,68 ----
for (Enumeration e = jar.entries(); e.hasMoreElements();) {
JarEntry entry = (JarEntry) e.nextElement();
InputStream is = jar.getInputStream(new ZipEntry(entry.getName()));
is.close();
}
+
+ // read(), available() on closed stream should throw IOException
+ InputStream is = jar.getInputStream(new ZipEntry("Test.class"));
+ is.close();
+ byte[] buffer = new byte[1];
+
+ try {
+ is.read();
+ throw new AssertionError("Should have thrown IOException");
+ } catch (IOException success) {}
+ try {
+ is.read(buffer);
+ throw new AssertionError("Should have thrown IOException");
+ } catch (IOException success) {}
+ try {
+ is.read(buffer, 0, buffer.length);
+ throw new AssertionError("Should have thrown IOException");
+ } catch (IOException success) {}
+ try {
+ is.available();
+ throw new AssertionError("Should have thrown IOException");
+ } catch (IOException success) {}
}
}
< prev index next >