1
1
/*
2
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
33
33
* @library /test/lib
34
34
* @build jdk.test.lib.RandomFactory
35
35
* @run main ReadAllReadNTransferTo
36
- * @bug 8180451
36
+ * @bug 6766844 8180451
37
37
* @summary Verify ByteArrayInputStream readAllBytes, readNBytes, and transferTo
38
38
* @key randomness
39
39
*/
@@ -48,8 +48,16 @@ public static void main(String... args) throws IOException {
48
48
int position = random .nextInt (SIZE /2 );
49
49
int size = random .nextInt (SIZE - position );
50
50
51
- ByteArrayInputStream bais =
52
- new ByteArrayInputStream (buf , position , size );
51
+ ByteArrayInputStream bais = new ByteArrayInputStream (buf );
52
+ bais .readAllBytes ();
53
+ if (bais .read (new byte [0 ]) != -1 ) {
54
+ throw new RuntimeException ("read(byte[]) did not return -1" );
55
+ }
56
+ if (bais .read (new byte [1 ], 0 , 0 ) != -1 ) {
57
+ throw new RuntimeException ("read(byte[],int,int) did not return -1" );
58
+ }
59
+
60
+ bais = new ByteArrayInputStream (buf , position , size );
53
61
int off = size < 2 ? 0 : random .nextInt (size / 2 );
54
62
int len = size - off < 1 ? 0 : random .nextInt (size - off );
55
63
@@ -72,7 +80,6 @@ public static void main(String... args) throws IOException {
72
80
throw new RuntimeException ("readAllBytes content" );
73
81
}
74
82
75
- // XXX transferTo()
76
83
bais = new ByteArrayInputStream (buf );
77
84
ByteArrayOutputStream baos = new ByteArrayOutputStream (buf .length );
78
85
if (bais .transferTo (baos ) != buf .length ) {
0 commit comments