mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8190500: (ch) ReadableByteChannelImpl::read and WritableByteChannelImpl::write might not throw ClosedChannelException as specified
Explicitly verify that the channel is open Reviewed-by: alanb
This commit is contained in:
parent
3803dc1401
commit
87eb47a3c8
2 changed files with 47 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -368,6 +368,10 @@ public final class Channels {
|
|||
|
||||
@Override
|
||||
public int read(ByteBuffer dst) throws IOException {
|
||||
if (!isOpen()) {
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
|
||||
int len = dst.remaining();
|
||||
int totalRead = 0;
|
||||
int bytesRead = 0;
|
||||
|
@ -442,6 +446,10 @@ public final class Channels {
|
|||
|
||||
@Override
|
||||
public int write(ByteBuffer src) throws IOException {
|
||||
if (!isOpen()) {
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
|
||||
int len = src.remaining();
|
||||
int totalWritten = 0;
|
||||
synchronized (writeLock) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue