You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by rs...@apache.org on 2026/02/07 00:01:14 UTC

(httpcomponents-core) branch 5.4.x updated: Ensure TCP-specific socket options are set

This is an automated email from the ASF dual-hosted git repository.

rschmitt pushed a commit to branch 5.4.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git


The following commit(s) were added to refs/heads/5.4.x by this push:
     new 17ce37aa2 Ensure TCP-specific socket options are set
17ce37aa2 is described below

commit 17ce37aa29a47e9ec3c0674f8606a83b9d3b3037
Author: Ryan Schmitt <rs...@apache.org>
AuthorDate: Fri Feb 6 15:53:02 2026 -0800

    Ensure TCP-specific socket options are set
    
    This change ensures that TCP-specific options are always set on
    applicable sockets, even when `socketChannel.getRemoteAddress()` returns
    `null`.
---
 .../main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
index 2d7004b77..dbda722e3 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
@@ -298,10 +298,11 @@ private void prepareSocket(final SocketChannel socketChannel) throws IOException
             socketChannel.setOption(StandardSocketOptions.SO_LINGER, linger);
         }
 
-        // None of the below options are applicable to Unix domain sockets.
-        if (!(socketChannel.getRemoteAddress() instanceof InetSocketAddress)) {
+        // None of the options below this point are applicable to Unix domain sockets.
+        if (!socketChannel.supportedOptions().contains(StandardSocketOptions.TCP_NODELAY)) {
             return;
         }
+
         socketChannel.setOption(StandardSocketOptions.TCP_NODELAY, this.reactorConfig.isTcpNoDelay());
         socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, this.reactorConfig.isSoKeepAlive());