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