Index: trunk/modules/luni/src/main/java/java/io/DataInputStream.java =================================================================== --- trunk/modules/luni/src/main/java/java/io/DataInputStream.java (revision 429584) +++ trunk/modules/luni/src/main/java/java/io/DataInputStream.java (working copy) @@ -189,23 +189,25 @@ */ public final void readFully(byte[] buffer, int offset, int length) throws IOException { - if (buffer != null) { - // avoid int overflow - if (0 <= offset && offset <= buffer.length && 0 <= length - && length <= buffer.length - offset) { - while (length > 0) { - int result = in.read(buffer, offset, length); - if (result >= 0) { - offset += result; - length -= result; - } else - throw new EOFException(); - } - } else - throw new IndexOutOfBoundsException(); - } else + if (buffer == null) throw new NullPointerException(org.apache.harmony.luni.util.Msg .getString("K0047")); //$NON-NLS-1$ + if (in == null) + throw new NullPointerException(org.apache.harmony.luni.util.Msg + .getString("KA00b")); //$NON-NLS-1$ + // avoid int overflow + if (0 <= offset && offset <= buffer.length && 0 <= length + && length <= buffer.length - offset) { + while (length > 0) { + int result = in.read(buffer, offset, length); + if (result >= 0) { + offset += result; + length -= result; + } else + throw new EOFException(); + } + } else + throw new IndexOutOfBoundsException(); } /** Index: trunk/modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java =================================================================== --- trunk/modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java (revision 429584) +++ trunk/modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java (working copy) @@ -186,7 +186,7 @@ /** * @tests java.io.DataInputStream#readFully(byte[], int, int) */ - public void test_readFully$BII() { + public void test_readFully$BII() throws IOException { // Test for method void java.io.DataInputStream.readFully(byte [], int, // int) try { @@ -200,6 +200,12 @@ } catch (IOException e) { fail("IOException during readFully test : " + e.getMessage()); } + //regression test for HARMONY-1103 + try { + new DataInputStream(null).readFully(new byte[] {2, 2, 2, 2}, 1, 18); + } catch (NullPointerException e) { + // expected + } } /**