Gracefully retry transport-level errors in osu http client
This commit is contained in:
parent
9206de7308
commit
250227d60e
@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.InitializingBean
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Service
|
||||
import java.io.IOException
|
||||
import java.net.URI
|
||||
import java.net.URLEncoder
|
||||
import java.net.http.HttpClient
|
||||
@ -346,7 +347,12 @@ class OsuApi(
|
||||
val waitTimes = listOf(15L, 30L, 60L)
|
||||
|
||||
for (waitTime in waitTimes) {
|
||||
val response = httpClient.send(request, HttpResponse.BodyHandlers.ofString())
|
||||
val response = try {
|
||||
httpClient.send(request, HttpResponse.BodyHandlers.ofString())
|
||||
} catch (ex: IOException) {
|
||||
// Some transport level exception might be thrown, continue with the retry backoff and see if it fixes itself
|
||||
continue
|
||||
}
|
||||
|
||||
this.logger.debug("Request: {}", request.uri())
|
||||
this.logger.debug("Result: {}", response.statusCode())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user