8329190: (ch) DatagramChannel.receive should throw ClosedChannelException when called on closed channel

Co-authored-by: Alan Bateman <alanb@openjdk.org>
Reviewed-by: jpai, michaelm
This commit is contained in:
Mark Sheppard 2024-04-16 15:44:15 +00:00
parent f11a496de6
commit 90df3b7fbb
6 changed files with 226 additions and 3 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2024, 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
@ -573,6 +573,7 @@ class DatagramChannelImpl
throw new IllegalArgumentException("Read-only buffer");
readLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
SocketAddress sender = null;
try {
@ -851,6 +852,7 @@ class DatagramChannelImpl
writeLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
int n;
boolean completed = false;
@ -1039,6 +1041,7 @@ class DatagramChannelImpl
readLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
int n = 0;
try {
@ -1069,6 +1072,7 @@ class DatagramChannelImpl
readLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
long n = 0;
try {
@ -1152,6 +1156,7 @@ class DatagramChannelImpl
writeLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
int n = 0;
try {
@ -1182,6 +1187,7 @@ class DatagramChannelImpl
writeLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
long n = 0;
try {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, 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
@ -392,6 +392,7 @@ class ServerSocketChannelImpl
acceptLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
try {
begin(blocking);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, 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
@ -955,6 +955,7 @@ class SocketChannelImpl
try {
writeLock.lock();
try {
ensureOpen();
boolean blocking = isBlocking();
boolean connected = false;
try {
@ -1053,6 +1054,7 @@ class SocketChannelImpl
if (isConnected())
return true;
ensureOpen();
boolean blocking = isBlocking();
boolean connected = false;
try {