--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2009/10/02 15:06:08 387 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2009/10/22 06:04:45 468 @@ -24,6 +24,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import dk.thoerup.circuitbreaker.CircuitBreakerException; import dk.thoerup.traininfoservice.DBConnection; /** @@ -39,7 +40,13 @@ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + if (req.getParameter("station") == null) { + resp.sendError(400, "not enough parameters"); + return; + } + int station = Integer.parseInt( req.getParameter("station") ); String format = req.getParameter("format"); @@ -49,11 +56,15 @@ try { beans = fetcher.cachedLookupDepartures(station); - } catch (java.net.SocketTimeoutException ste) { - logger.warning("Read timed out, station="+station); + } catch (java.io.IOException ioe) { + logger.warning("Read failed, station="+station + ". " + ioe.getMessage() ); + resp.sendError(500); + return; + } catch (CircuitBreakerException cbe) { + logger.warning("Circuitbreaker - failing fast"); resp.sendError(500); return; - } catch (Exception e) { + } catch (Exception e) { logger.log(Level.WARNING, "Unknown exception, station=" +station, e); resp.sendError(500); return;