ppkarwasz commented on code in PR #784:
URL: https://github.com/apache/commons-io/pull/784#discussion_r2366836910


##########
src/main/java/org/apache/commons/io/channels/ByteArraySeekableByteChannel.java:
##########
@@ -37,41 +37,67 @@
  * accessed via {@link ByteArraySeekableByteChannel#array()}.
  * </p>
  *
- * @since 2.19.0
+ * @since 2.21.0
  */
 public class ByteArraySeekableByteChannel implements SeekableByteChannel {
 
     private static final int RESIZE_LIMIT = Integer.MAX_VALUE >> 1;
-    private byte[] data;
-    private final AtomicBoolean closed = new AtomicBoolean();
+
+    /**
+     * Constructs a channel that wraps the given byte array.
+     * <p>
+     * The resulting channel will share the given array as its buffer, until a 
write operation
+     * requires a larger capacity.
+     * The initial size of the channel is the length of the given array, and 
the initial position is 0.
+     * </p>
+     * @param bytes The byte array to wrap; must not be {@code null}.
+     * @return A new channel that wraps the given byte array; never {@code 
null}.
+     * @throws NullPointerException If the byte array is {@code null}.
+     */
+    public static ByteArraySeekableByteChannel wrap(byte[] bytes) {
+        Objects.requireNonNull(bytes, "bytes");
+        return new ByteArraySeekableByteChannel(bytes, bytes.length);
+    }
+
+    // package-private for testing
+    byte[] data;

Review Comment:
   Fixed in 
https://github.com/apache/commons-io/pull/784/commits/0c853487783a43abb85de3fcc204ecca3a5ca421



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to