Skip to content

Commit 0e7654b

Browse files
authored
http (fix): Fixes #3421 Retry upon GOAWAY message from HTTP/2 servers (#3422)
JDK's HttpClient throws IOException with "(address): GOAWAY received" error message. This PR addresses this error.
1 parent 41d709a commit 0e7654b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

airframe-http/src/main/scala/wvlet/airframe/http/HttpClientException.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import wvlet.airframe.control.Retry.RetryContext
1717
import wvlet.airframe.control.{CircuitBreakerOpenException, ResultClass}
1818
import wvlet.log.LogSupport
1919

20-
import java.io.EOFException
20+
import java.io.{IOException, EOFException}
2121
import java.lang.reflect.InvocationTargetException
2222
import java.net.*
2323
import java.nio.channels.ClosedChannelException
@@ -181,14 +181,18 @@ object HttpClientException extends LogSupport {
181181
case e: SocketTimeoutException => retryableFailure(e)
182182
case e: SocketException =>
183183
e match {
184-
case se: BindException => retryableFailure(e)
185-
case se: ConnectException => retryableFailure(e)
186-
case se: NoRouteToHostException => retryableFailure(e)
187-
case se: PortUnreachableException => retryableFailure(e)
188-
case se if se.getMessage == "Socket closed" => retryableFailure(e)
184+
case se: BindException => retryableFailure(e)
185+
case se: ConnectException => retryableFailure(e)
186+
case se: NoRouteToHostException => retryableFailure(e)
187+
case se: PortUnreachableException => retryableFailure(e)
188+
case se if se.getMessage() == "Socket closed" => retryableFailure(e)
189189
case other =>
190190
nonRetryableFailure(e)
191191
}
192+
// HTTP/2 may disconnects the connection with "GOAWAY received" error https://github.com/wvlet/airframe/issues/3421
193+
// See also the code of jdk.internal.net.http.Http2Connection.handleGoAway
194+
case e: IOException if Option(e.getMessage()).exists(_.contains("GOAWAY received")) =>
195+
retryableFailure(e)
192196
// Exceptions from Finagle. Using the string class names so as not to include Finagle dependencies.
193197
case e: Throwable if isRetryableFinagleException(e) =>
194198
retryableFailure(e)

0 commit comments

Comments
 (0)