Gracefully retry transport-level errors in osu http client

This commit is contained in:
Stedoss 2025-02-20 01:31:55 +00:00
parent 9206de7308
commit 250227d60e

View File

@ -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())