diff options
author | Anton Tananaev <anton@traccar.org> | 2022-12-13 07:35:58 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-12-13 07:35:58 -0800 |
commit | a87c77da9e8d39856e2a16ae3d3aa385e068a1e8 (patch) | |
tree | 5485df09c175714d6d2d05d8f1c9385d2919c5a8 /src/main/java/org/traccar | |
parent | 1a39c3ed8ddf78acdc50e25aae76f647243f2a00 (diff) | |
download | trackermap-server-a87c77da9e8d39856e2a16ae3d3aa385e068a1e8.tar.gz trackermap-server-a87c77da9e8d39856e2a16ae3d3aa385e068a1e8.tar.bz2 trackermap-server-a87c77da9e8d39856e2a16ae3d3aa385e068a1e8.zip |
Handle missing user id
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r-- | src/main/java/org/traccar/api/AsyncSocketServlet.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/api/AsyncSocketServlet.java b/src/main/java/org/traccar/api/AsyncSocketServlet.java index 40e1551a1..91a745eeb 100644 --- a/src/main/java/org/traccar/api/AsyncSocketServlet.java +++ b/src/main/java/org/traccar/api/AsyncSocketServlet.java @@ -51,11 +51,12 @@ public class AsyncSocketServlet extends JettyWebSocketServlet { factory.setIdleTimeout(Duration.ofMillis(config.getLong(Keys.WEB_TIMEOUT))); factory.setCreator((req, resp) -> { if (req.getSession() != null) { - long userId = (Long) ((HttpSession) req.getSession()).getAttribute(SessionResource.USER_ID_KEY); - return new AsyncSocket(objectMapper, connectionManager, storage, userId); - } else { - return null; + Long userId = (Long) ((HttpSession) req.getSession()).getAttribute(SessionResource.USER_ID_KEY); + if (userId != null) { + return new AsyncSocket(objectMapper, connectionManager, storage, userId); + } } + return null; }); } |