aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/http
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-30 10:13:56 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-30 10:13:56 +1200
commiteeb9ed411959496d35f84650a158a244b0137a93 (patch)
treedc50f3c1851e2fb7d2d83bdcf9bf7aaefaa5e204 /src/org/traccar/http
parent8aa3c641b0eeaed02a0740d2c7ca89708cdf4d1b (diff)
downloadtrackermap-server-eeb9ed411959496d35f84650a158a244b0137a93.tar.gz
trackermap-server-eeb9ed411959496d35f84650a158a244b0137a93.tar.bz2
trackermap-server-eeb9ed411959496d35f84650a158a244b0137a93.zip
Handle async servlet exceptions
Diffstat (limited to 'src/org/traccar/http')
-rw-r--r--src/org/traccar/http/AsyncServlet.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/org/traccar/http/AsyncServlet.java b/src/org/traccar/http/AsyncServlet.java
index e9cb35840..2ccb73f06 100644
--- a/src/org/traccar/http/AsyncServlet.java
+++ b/src/org/traccar/http/AsyncServlet.java
@@ -41,13 +41,14 @@ import org.traccar.helper.Log;
import org.traccar.model.Position;
import org.traccar.model.User;
-public class AsyncServlet extends HttpServlet {
+public class AsyncServlet extends BaseServlet {
private static final long ASYNC_TIMEOUT = 120000;
@Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- async(req.startAsync());
+ protected boolean handle(String command, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ async(req.startAsync(), getUserId(req));
+ return true;
}
public class AsyncSession {
@@ -194,20 +195,19 @@ public class AsyncServlet extends HttpServlet {
}
}
- private void async(final AsyncContext context) {
+ private void async(final AsyncContext context, long userId) {
context.setTimeout(ASYNC_TIMEOUT);
HttpServletRequest req = (HttpServletRequest) context.getRequest();
- User user = (User) req.getSession().getAttribute(MainServlet.USER_KEY);
-
+
synchronized (asyncSessions) {
- if (Boolean.valueOf(req.getParameter("first")) || !asyncSessions.containsKey(user.getId())) {
- Collection<Long> devices = Context.getPermissionsManager().allowedDevices(user.getId());
- asyncSessions.put(user.getId(), new AsyncSession(user.getId(), devices));
+ if (Boolean.valueOf(req.getParameter("first")) || !asyncSessions.containsKey(userId)) {
+ Collection<Long> devices = Context.getPermissionsManager().allowedDevices(userId);
+ asyncSessions.put(userId, new AsyncSession(userId, devices));
}
- asyncSessions.get(user.getId()).request(context);
+ asyncSessions.get(userId).request(context);
}
}