Showing
1 changed file
with
15 additions
and
4 deletions
... | ... | @@ -23,6 +23,7 @@ import java.util.concurrent.ConcurrentHashMap; |
23 | 23 | import java.util.concurrent.ConcurrentMap; |
24 | 24 | |
25 | 25 | import lombok.extern.slf4j.Slf4j; |
26 | +import org.springframework.beans.factory.BeanCreationNotAllowedException; | |
26 | 27 | import org.springframework.context.annotation.Lazy; |
27 | 28 | import org.springframework.web.bind.annotation.RequestMapping; |
28 | 29 | import org.springframework.web.bind.annotation.RestController; |
... | ... | @@ -57,10 +58,12 @@ public class PluginWebSocketHandler extends TextWebSocketHandler implements Plug |
57 | 58 | private static final ConcurrentMap<String, SessionMetaData> internalSessionMap = new ConcurrentHashMap<>(); |
58 | 59 | private static final ConcurrentMap<String, String> externalSessionMap = new ConcurrentHashMap<>(); |
59 | 60 | |
60 | - @Autowired @Lazy | |
61 | + @Autowired | |
62 | + @Lazy | |
61 | 63 | private ActorService actorService; |
62 | 64 | |
63 | - @Autowired @Lazy | |
65 | + @Autowired | |
66 | + @Lazy | |
64 | 67 | private PluginService pluginService; |
65 | 68 | |
66 | 69 | @Override |
... | ... | @@ -105,7 +108,7 @@ public class PluginWebSocketHandler extends TextWebSocketHandler implements Plug |
105 | 108 | super.handleTransportError(session, tError); |
106 | 109 | SessionMetaData sessionMd = internalSessionMap.get(session.getId()); |
107 | 110 | if (sessionMd != null) { |
108 | - actorService.process(new SessionEventPluginWebSocketMsg(sessionMd.sessionRef, SessionEvent.onError(tError))); | |
111 | + processInActorService(new SessionEventPluginWebSocketMsg(sessionMd.sessionRef, SessionEvent.onError(tError))); | |
109 | 112 | } else { |
110 | 113 | log.warn("[{}] Failed to find session", session.getId()); |
111 | 114 | } |
... | ... | @@ -118,11 +121,19 @@ public class PluginWebSocketHandler extends TextWebSocketHandler implements Plug |
118 | 121 | SessionMetaData sessionMd = internalSessionMap.remove(session.getId()); |
119 | 122 | if (sessionMd != null) { |
120 | 123 | externalSessionMap.remove(sessionMd.sessionRef.getSessionId()); |
121 | - actorService.process(new SessionEventPluginWebSocketMsg(sessionMd.sessionRef, SessionEvent.onClosed())); | |
124 | + processInActorService(new SessionEventPluginWebSocketMsg(sessionMd.sessionRef, SessionEvent.onClosed())); | |
122 | 125 | } |
123 | 126 | log.info("[{}] Session is closed", session.getId()); |
124 | 127 | } |
125 | 128 | |
129 | + private void processInActorService(SessionEventPluginWebSocketMsg msg) { | |
130 | + try { | |
131 | + actorService.process(msg); | |
132 | + } catch (BeanCreationNotAllowedException e) { | |
133 | + log.warn("[{}] Failed to close session due to possible shutdown state", msg.getSessionRef().getSessionId()); | |
134 | + } | |
135 | + } | |
136 | + | |
126 | 137 | private PluginWebsocketSessionRef toRef(WebSocketSession session) throws IOException { |
127 | 138 | URI sessionUri = session.getUri(); |
128 | 139 | String path = sessionUri.getPath(); | ... | ... |