Fixed issue 38361. The terminal does not go to offline mode if the database is colapsed but the tomcat works
authorAntonio Moreno <antonio.moreno@openbravo.com>
Thu, 11 Oct 2018 18:18:19 +0200
changeset 34840 31f161352319
parent 34839 44a01083360d
child 34841 618fcb380761
Fixed issue 38361. The terminal does not go to offline mode if the database is colapsed but the tomcat works
When there is an exception in the critical part of the HttpSecureAppServlet which tries to detect if the client is authenticated, we should not necessarily force a logout and reply with '401- Not authenticated' response. Instead, the appropriate action is to just return a '500-Internal Server Error' response. Logging out in this case may kill a valid request when the server is temporarily overloaded, and makes no sense, and the 401 response may confuse the client, thinking that it needs to do login again when in reality, the problem is just that the server is either overloaded, or affected by some serious problem which prevents even basic authentication checking to work.
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java	Thu Oct 11 10:01:13 2018 +0200
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java	Thu Oct 11 18:18:19 2018 +0200
@@ -357,7 +357,7 @@
     } catch (final Exception e) {
       // Re-login
       log4j.error("HTTPSecureAppServlet.service() - exception caught: ", e);
-      logout(request, response);
+      response.setStatus(500);
       return;
     } finally {
       final boolean sessionCreated = !sessionExists && null != request.getSession(false);