zentol commented on a change in pull request #17227:
URL: https://github.com/apache/flink/pull/17227#discussion_r705695170
##########
File path: flink-core/src/main/java/org/apache/flink/util/NetUtils.java
##########
@@ -116,6 +119,39 @@ private static URL validateHostPortString(String hostPort)
{
}
}
+ /**
+ * Calls {@link ServerSocket#accept()} on the provided server socket,
suppressing any thrown
+ * {@link SocketTimeoutException}s. This is a workaround for the
underlying JDK-8237858 bug in
+ * JDK 11 that can cause errant SocketTimeoutExceptions to be thrown at
unexpected times.
+ *
+ * <p>This method expects the provided ServerSocket has no timeout set
(SO_TIMEOUT of 0),
+ * indicating an infinite timeout. It will suppress all
SocketTimeoutExceptions, even if a
+ * ServerSocket with a non-zero timeout is passed in.
+ *
+ * @param serverSocket a ServerSocket with {@link SocketOptions#SO_TIMEOUT
SO_TIMEOUT} set to 0;
+ * if SO_TIMEOUT is greater than 0, then this method will suppress
SocketTimeoutException;
Review comment:
>The fact that it throws IOExceptions gave me pause.
That's a fair point but it's probably not an issue. I'd wager a guess that
this only fails if say, the socket is already closed. If getting an option
throws an error the socket is probably unusable anyway 🤷
Performance doesn't matter in this case; sockets aren't created on
performance-critical paths.
So let's do something like
```
Preconditions.checkArgument(serverSocket.getSoTimeout() == 0, "<some
reason>");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]