mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8318677: (ch) Add implNote about minBufferCap to main variant of Channels.newWriter
Reviewed-by: alanb, rriggs
This commit is contained in:
parent
864a876ebf
commit
d3534b08b5
2 changed files with 6 additions and 3 deletions
|
@ -523,6 +523,9 @@ public final class Channels {
|
||||||
* The resulting stream will not otherwise be buffered. Closing the stream
|
* The resulting stream will not otherwise be buffered. Closing the stream
|
||||||
* will in turn cause the channel to be closed. </p>
|
* will in turn cause the channel to be closed. </p>
|
||||||
*
|
*
|
||||||
|
* @implNote
|
||||||
|
* The value of {@code minBufferCap} is ignored.
|
||||||
|
*
|
||||||
* @param ch
|
* @param ch
|
||||||
* The channel to which bytes will be written
|
* The channel to which bytes will be written
|
||||||
*
|
*
|
||||||
|
@ -532,7 +535,8 @@ public final class Channels {
|
||||||
* @param minBufferCap
|
* @param minBufferCap
|
||||||
* The minimum capacity of the internal byte buffer,
|
* The minimum capacity of the internal byte buffer,
|
||||||
* or {@code -1} if an implementation-dependent
|
* 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
|
* @return A new writer
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class NewWriter {
|
||||||
private int actual = 0;
|
private int actual = 0;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void oneByteChannel() throws IOException {
|
public void customWritableByteChannel() throws IOException {
|
||||||
try (Writer writer = Channels.newWriter(new WritableByteChannel() {
|
try (Writer writer = Channels.newWriter(new WritableByteChannel() {
|
||||||
@Override
|
@Override
|
||||||
public int write(ByteBuffer src) {
|
public int write(ByteBuffer src) {
|
||||||
|
@ -89,7 +89,6 @@ public class NewWriter {
|
||||||
ss.bind(new InetSocketAddress(lb, 0));
|
ss.bind(new InetSocketAddress(lb, 0));
|
||||||
sc.connect(ss.getLocalSocketAddress());
|
sc.connect(ss.getLocalSocketAddress());
|
||||||
sc.configureBlocking(false);
|
sc.configureBlocking(false);
|
||||||
sc.setOption(StandardSocketOptions.SO_SNDBUF, 8192);
|
|
||||||
try (Writer writer = Channels.newWriter(sc,
|
try (Writer writer = Channels.newWriter(sc,
|
||||||
StandardCharsets.UTF_8)) {
|
StandardCharsets.UTF_8)) {
|
||||||
for (int i = 1; i < Integer.MAX_VALUE; i++) {
|
for (int i = 1; i < Integer.MAX_VALUE; i++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue