Summary
Modify the specification of the minBufferCap
parameter of the principal, three-parameter variant of java.nio.channels.Channels.newWriter
to indicate that it is ignored.
Problem
The implementation of this variant of Channels.newWriter
allowed for problematic behavior and required duplicate implementations for OutputStream
and WritableByteChannel
.
Solution
Remove WritableByteChannel
support in StreamEncoder
and instead use an OutputStream
that wraps a WritableByteChannel
.
Specification
--- a/src/java.base/share/classes/java/nio/channels/Channels.java
+++ b/src/java.base/share/classes/java/nio/channels/Channels.java
@@ -521,20 +521,24 @@
* channel; if the channel is in non-blocking mode when bytes are to be
* written then an {@link IllegalBlockingModeException} will be thrown.
* 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
*
* @param enc
* The charset encoder to be used
*
* @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
*/
public static Writer newWriter(WritableByteChannel ch,
CharsetEncoder enc,
- csr of
-
JDK-8318677 (ch) Add implNote about minBufferCap to main variant of Channels.newWriter
-
- Resolved
-