RFR: 8245036: DataInputStream.readFully(byte[], int, int) does not throw expected IndexOutOfBoundsExceptions

Brian Burkhalter brian.burkhalter at oracle.com
Wed Aug 5 16:20:08 UTC 2020


HI Raffaello,

The implementation test looks right. In the test, you might consider using try-with-resources.

Thanks,

Brian

> On Jul 29, 2020, at 10:44 AM, Raffaello Giulietti <raffaello.giulietti at gmail.com> wrote:
> 
> +        FileInputStream in = new FileInputStream(file);
> +        DataInputStream dis = new DataInputStream(in);
> +
> +        boolean caughtException = false;
> +        try {
> +            dis.readFully(buffer, -1, buffer.length);
> +        } catch (IndexOutOfBoundsException ie) {
> +            caughtException = true;
> +        } finally {
> +            dis.close();
> +            if (!caughtException)
> +                throw new RuntimeException("Test testNegativeOffset() failed");
> +        }



More information about the core-libs-dev mailing list