This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new c682914475 Fix a Coverity resource leak warning.
c682914475 is described below
commit c6829144754bbcd177009d60e204d52a1a48f971
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 28 12:57:43 2026 +0100
Fix a Coverity resource leak warning.
---
.../catalina/tribes/transport/nio/NioReceiver.java | 44 ++++++++++++++++------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
b/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
index 49acb3238b..b0e819a089 100644
--- a/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
+++ b/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
@@ -110,8 +110,18 @@ public class NioReceiver extends ReceiverBase implements
Runnable, NioReceiverMB
while (server != null && server.isOpen()) {
try {
SocketChannel socket = server.accept();
- socket.configureBlocking(true);
- socket.socket().setSoTimeout(getTimeout());
+ try {
+ socket.configureBlocking(true);
+ socket.socket().setSoTimeout(getTimeout());
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ try {
+ socket.close();
+ } catch (IOException ioe) {
+ t.addSuppressed(ioe);
+ }
+ throw t;
+ }
Semaphore connectionSlots = secureConnectionSlots;
if (connectionSlots == null || !connectionSlots.tryAcquire()) {
socket.close();
@@ -493,16 +503,26 @@ public class NioReceiver extends ReceiverBase implements
Runnable, NioReceiverMB
if (key.isAcceptable()) {
ServerSocketChannel server = (ServerSocketChannel)
key.channel();
SocketChannel channel = server.accept();
- channel.socket().setReceiveBufferSize(getRxBufSize());
- channel.socket().setSendBufferSize(getTxBufSize());
- channel.socket().setTcpNoDelay(getTcpNoDelay());
- channel.socket().setKeepAlive(getSoKeepAlive());
- channel.socket().setOOBInline(getOoBInline());
- channel.socket().setReuseAddress(getSoReuseAddress());
- channel.socket().setSoLinger(getSoLingerOn(),
getSoLingerTime());
- channel.socket().setSoTimeout(getTimeout());
- Object attach = new ObjectReader(channel);
- registerChannel(selector, channel,
SelectionKey.OP_READ, attach);
+ try {
+
channel.socket().setReceiveBufferSize(getRxBufSize());
+ channel.socket().setSendBufferSize(getTxBufSize());
+ channel.socket().setTcpNoDelay(getTcpNoDelay());
+ channel.socket().setKeepAlive(getSoKeepAlive());
+ channel.socket().setOOBInline(getOoBInline());
+
channel.socket().setReuseAddress(getSoReuseAddress());
+ channel.socket().setSoLinger(getSoLingerOn(),
getSoLingerTime());
+ channel.socket().setSoTimeout(getTimeout());
+ Object attach = new ObjectReader(channel);
+ registerChannel(selector, channel,
SelectionKey.OP_READ, attach);
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ try {
+ channel.close();
+ } catch (IOException ioe) {
+ t.addSuppressed(ioe);
+ }
+ throw t;
+ }
}
// is there data to read on this channel?
if (key.isReadable()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]