Skip to content

Commit

Permalink
DEV2-4011 Retry get server url (#661)
Browse files Browse the repository at this point in the history
* log error in warn level - to avoid prompting the user

* retry get server url in case of failure
  • Loading branch information
amircodota authored Oct 16, 2023
1 parent 30ebe77 commit fe14b31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object ChatMessagesRouter {

return ChatMessageResponse(request.id, responsePayload)
} catch (e: Exception) {
Logger.getInstance(ChatMessagesRouter::class.java).error("Failed to handle request '${request.command}'", e)
Logger.getInstance(ChatMessagesRouter::class.java).warn("Failed to handle request '${request.command}'", e)
return ChatMessageResponse(request.id, error = e.message ?: e.toString())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ data class ServerUrlResponse(val serverUrl: String)
class GetServerUrlHandler(gson: Gson) : ChatMessageHandler<ServerUrlRequest, ServerUrlResponse>(gson) {
override fun handle(payload: ServerUrlRequest?, project: Project): ServerUrlResponse {
if (CapabilitiesService.getInstance().isCapabilityEnabled(Capability.CHAT_URL_FROM_BINARY) && payload != null) {
val response = DependencyContainer.instanceOfBinaryRequestFacade().executeRequest(ChatCommunicatorAddressRequest(payload.kind))
val request = ChatCommunicatorAddressRequest(payload.kind)
var response = DependencyContainer.instanceOfBinaryRequestFacade().executeRequest(
request
)

// retry if failed
// might happen if binary just restarted
if (response == null) {
response = DependencyContainer.instanceOfBinaryRequestFacade().executeRequest(
request
)
}

return ServerUrlResponse(response.address)
}

Expand Down

0 comments on commit fe14b31

Please sign in to comment.