Skip to content
Permalink
Browse files
8241952: (fs) FileChannel.write(ByteBuffer src, long position) does n…
…ot check for the FileChannel being closed first

Reviewed-by: lancea, alanb
  • Loading branch information
Brian Burkhalter committed Apr 13, 2020
1 parent 447d649 commit ea36a53b753de862ad1301e4a5d71830b18fd327
Showing 1 changed file with 4 additions and 6 deletions.
@@ -240,8 +240,7 @@ public int read(ByteBuffer dst) throws IOException {
public long read(ByteBuffer[] dsts, int offset, int length)
throws IOException
{
if ((offset < 0) || (length < 0) || (offset > dsts.length - length))
throw new IndexOutOfBoundsException();
Objects.checkFromIndexSize(offset, length, dsts.length);
ensureOpen();
if (!readable)
throw new NonReadableChannelException();
@@ -297,8 +296,7 @@ public int write(ByteBuffer src) throws IOException {
public long write(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
if ((offset < 0) || (length < 0) || (offset > srcs.length - length))
throw new IndexOutOfBoundsException();
Objects.checkFromIndexSize(offset, length, srcs.length);
ensureOpen();
if (!writable)
throw new NonWritableChannelException();
@@ -789,11 +787,11 @@ public int read(ByteBuffer dst, long position) throws IOException {
throw new NullPointerException();
if (position < 0)
throw new IllegalArgumentException("Negative position");
ensureOpen();
if (!readable)
throw new NonReadableChannelException();
if (direct)
Util.checkChannelPositionAligned(position, alignment);
ensureOpen();
if (nd.needsPositionLock()) {
synchronized (positionLock) {
return readInternal(dst, position);
@@ -829,11 +827,11 @@ public int write(ByteBuffer src, long position) throws IOException {
throw new NullPointerException();
if (position < 0)
throw new IllegalArgumentException("Negative position");
ensureOpen();
if (!writable)
throw new NonWritableChannelException();
if (direct)
Util.checkChannelPositionAligned(position, alignment);
ensureOpen();
if (nd.needsPositionLock()) {
synchronized (positionLock) {
return writeInternal(src, position);

0 comments on commit ea36a53

Please sign in to comment.