From 0fe85ed6ff51c72cdc3d01fcce55ea795a38c828 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 9 Feb 2022 19:59:01 +0000 Subject: [PATCH] Ignore http 503 error from socket server --- .../common/webeditor/WebEditorSession.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorSession.java b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorSession.java index cb29b1bbd..16611a0f3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorSession.java +++ b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorSession.java @@ -98,16 +98,25 @@ public class WebEditorSession { this.socket = socket; this.plugin.getWebEditorStore().sockets().putSocket(this.sender, this.socket); } catch (Exception e) { - if (e instanceof UnsuccessfulRequestException && ((UnsuccessfulRequestException) e).getResponse().code() == 502) { - // 502 - bad gateway, probably means the socket service is offline - // that's ok, no need to send a warning - return; + if (!ignoreSocketConnectError(e)) { + this.plugin.getLogger().warn("Unable to establish socket connection", e); } - - this.plugin.getLogger().warn("Unable to establish socket connection", e); } } + private static boolean ignoreSocketConnectError(Exception e) { + if (e instanceof UnsuccessfulRequestException) { + UnsuccessfulRequestException req = (UnsuccessfulRequestException) e; + int code = req.getResponse().code(); + + // 502 - bad gateway / 503 - service unavailable + // probably means the socket service is offline, that's ok, no need to send a warning + return code == 502 || code == 503; + } + + return false; + } + private void createInitialSession() { Objects.requireNonNull(this.initialRequest);