我正在使用 Java 11 http-client ( java.net.http)。
该send()方法声明了这些异常:
@throws IOException
@throws InterruptedException
@throws IllegalArgumentException
@throws SecurityException
Run Code Online (Sandbox Code Playgroud)
我对捕获超时引起的异常感兴趣。我认为最好的方法是抓住
HttpTimeoutException(扩展IOException)
但是,我有时会看到,当发生超时时,引发的异常是:
java.io.IOException: Connection timed out
Run Code Online (Sandbox Code Playgroud)
现在我想知道: