--- old/test/jdk/java/io/InputStream/NullInputStream.java 2018-01-24 11:34:01.000000000 -0800 +++ new/test/jdk/java/io/InputStream/NullInputStream.java 2018-01-24 11:34:00.000000000 -0800 @@ -31,7 +31,7 @@ /* * @test - * @bug 4358774 + * @bug 4358774 8139206 * @run testng NullInputStream * @summary Check for expected behavior of InputStream.nullInputStream(). */ @@ -107,7 +107,7 @@ } @Test(groups = "open") - public static void testreadNBytes() { + public static void testReadNBytes() { try { assertEquals(0, openStream.readNBytes(new byte[1], 0, 1), "readNBytes(byte[],int,int) != 0"); @@ -117,6 +117,26 @@ } @Test(groups = "open") + public static void testReadNBytesWithLength() { + try { + assertEquals(0, openStream.readNBytes(-1).length, + "readNBytes(-1) != 0"); + fail("Expected IllegalArgumentException not thrown"); + } catch (IllegalArgumentException iae) { + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + try { + assertEquals(0, openStream.readNBytes(0).length, + "readNBytes(0, false) != 0"); + assertEquals(0, openStream.readNBytes(1).length, + "readNBytes(1, false) != 0"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") public static void testSkip() { try { assertEquals(0, openStream.skip(1), "skip() != 0"); @@ -181,6 +201,15 @@ } @Test(groups = "closed") + public static void testReadNBytesWithLengthClosed() { + try { + closedStream.readNBytes(1); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") public static void testSkipClosed() { try { closedStream.skip(1);