8318677: (ch) Add implNote about minBufferCap to main variant of Channels.newWriter

Reviewed-by: alanb, rriggs
This commit is contained in:
Brian Burkhalter 2023-10-30 18:28:01 +00:00
parent 864a876ebf
commit d3534b08b5
2 changed files with 6 additions and 3 deletions
src/java.base/share/classes/java/nio/channels
test/jdk/java/nio/channels/Channels

@ -523,6 +523,9 @@ public final class Channels {
* The resulting stream will not otherwise be buffered. Closing the stream
* will in turn cause the channel to be closed. </p>
*
* @implNote
* The value of {@code minBufferCap} is ignored.
*
* @param ch
* The channel to which bytes will be written
*
@ -532,7 +535,8 @@ public final class Channels {
* @param minBufferCap
* The minimum capacity of the internal byte buffer,
* or {@code -1} if an implementation-dependent
* default capacity is to be used
* default capacity is to be used. The value of
* {@code minBufferCap} may be ignored
*
* @return A new writer
*/

@ -51,7 +51,7 @@ public class NewWriter {
private int actual = 0;
@Test
public void oneByteChannel() throws IOException {
public void customWritableByteChannel() throws IOException {
try (Writer writer = Channels.newWriter(new WritableByteChannel() {
@Override
public int write(ByteBuffer src) {
@ -89,7 +89,6 @@ public class NewWriter {
ss.bind(new InetSocketAddress(lb, 0));
sc.connect(ss.getLocalSocketAddress());
sc.configureBlocking(false);
sc.setOption(StandardSocketOptions.SO_SNDBUF, 8192);
try (Writer writer = Channels.newWriter(sc,
StandardCharsets.UTF_8)) {
for (int i = 1; i < Integer.MAX_VALUE; i++) {