From 23bab19229ad582e5739fbd05eaf445d8dd3a480 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 24 Aug 2021 18:43:38 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-55048=20https=E8=BF=9C=E7=A8=8B=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=97=B6=EF=BC=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E4=B8=8A?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E8=BF=87=E6=9D=A5=E7=9A=84eventhread?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=97=A5=E5=BF=97=20fix=20npe=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 2 ++ .../env/DesignerWorkspaceInfoContext.java | 20 +++++++++++++++++++ .../mainframe/socketio/DesignerSocketIO.java | 15 +++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 6881c8445..cd9c835f3 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -8,6 +8,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteWorkspace; @@ -105,6 +106,7 @@ public class EnvChangeEntrance { private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); try { diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java new file mode 100644 index 000000000..ba8a5b09f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java @@ -0,0 +1,20 @@ +package com.fr.design.env; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/24 + */ +public class DesignerWorkspaceInfoContext { + + private static DesignerWorkspaceInfo workspaceInfo; + + public static DesignerWorkspaceInfo getWorkspaceInfo() { + return workspaceInfo; + } + + public static void setWorkspaceInfo(DesignerWorkspaceInfo workspaceInfo) { + DesignerWorkspaceInfoContext.workspaceInfo = workspaceInfo; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index c1e994bdc..5f3e57b26 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -6,6 +6,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.loghandler.DesignerLogger; @@ -127,9 +128,7 @@ public class DesignerSocketIO { } private static SSLContext getSSLContext() throws Exception { - String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); - WorkspaceConnectionInfo connection = info.getConnection(); + WorkspaceConnectionInfo connection = getConnectionInfo(); String certPath = connection.getCertPath(); String certSecretKey = connection.getCertSecretKey(); if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { @@ -144,6 +143,16 @@ public class DesignerSocketIO { .build(); } + private static WorkspaceConnectionInfo getConnectionInfo() { + if (DesignerWorkspaceInfoContext.getWorkspaceInfo() == null) { + String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); + DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); + return info.getConnection(); + } else { + return DesignerWorkspaceInfoContext.getWorkspaceInfo().getConnection(); + } + } + private static String[] getSocketUri() throws IOException { Workspace current = WorkContext.getCurrent(); URL url = new URL(current.getPath());