aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/AsyncSocketServlet.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-05 11:15:24 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-05 11:15:24 +1300
commit10fff38e197140d9966ca81185dc5e8f25983ffb (patch)
tree5e7799e2803db22fb16500cadec2a034a34fe663 /src/org/traccar/api/AsyncSocketServlet.java
parent507cc9154d8a40d96fd52447380120c9c3a5b98c (diff)
downloadtrackermap-server-10fff38e197140d9966ca81185dc5e8f25983ffb.tar.gz
trackermap-server-10fff38e197140d9966ca81185dc5e8f25983ffb.tar.bz2
trackermap-server-10fff38e197140d9966ca81185dc5e8f25983ffb.zip
Handle some async socket exceptions
Diffstat (limited to 'src/org/traccar/api/AsyncSocketServlet.java')
-rw-r--r--src/org/traccar/api/AsyncSocketServlet.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/org/traccar/api/AsyncSocketServlet.java b/src/org/traccar/api/AsyncSocketServlet.java
index edfa8939b..ef6cef732 100644
--- a/src/org/traccar/api/AsyncSocketServlet.java
+++ b/src/org/traccar/api/AsyncSocketServlet.java
@@ -33,8 +33,12 @@ public class AsyncSocketServlet extends WebSocketServlet {
factory.setCreator(new WebSocketCreator() {
@Override
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
- long userId = (Long) req.getSession().getAttribute(SessionResource.USER_ID_KEY);
- return new AsyncSocket(userId);
+ if (req.getSession() != null) {
+ long userId = (Long) req.getSession().getAttribute(SessionResource.USER_ID_KEY);
+ return new AsyncSocket(userId);
+ } else {
+ return null;
+ }
}
});
}