diff options
author | Artur Signell <artur@vaadin.com> | 2013-03-21 12:49:08 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-02 07:49:30 +0000 |
commit | d0c7dabbb1c32dd187699ba034ad45474ec633c3 (patch) | |
tree | 1fcc7ad805740a82f8f93347e95f9c4c2a2dd994 | |
parent | 507a520f0c042e2593eac196b7a1daa9de814bed (diff) | |
download | vaadin-framework-d0c7dabbb1c32dd187699ba034ad45474ec633c3.tar.gz vaadin-framework-d0c7dabbb1c32dd187699ba034ad45474ec633c3.zip |
Fixed locking problem with serviceException (#10569)
Change-Id: I363ac3508f558769a79098572cb268cadfc4b1e2
-rw-r--r-- | server/src/com/vaadin/server/VaadinPortlet.java | 46 | ||||
-rw-r--r-- | server/src/com/vaadin/server/VaadinServlet.java | 45 |
2 files changed, 56 insertions, 35 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index 75d72be03b..9dd8a4c94b 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -611,25 +611,35 @@ public class VaadinPortlet extends GenericPortlet implements Constants, Throwable e) throws IOException, PortletException { // TODO Check that this error handler is working when running inside a // portlet - - // if this was an UIDL request, response UIDL back to client - ErrorHandler errorHandler = ErrorEvent.findErrorHandler(vaadinSession); - if (getRequestType(request) == RequestType.UIDL) { - SystemMessages ci = getService().getSystemMessages( - ServletPortletHelper.findLocale(null, vaadinSession, - request), request); - criticalNotification(request, response, - ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), - null, ci.getInternalErrorURL()); - if (errorHandler != null) { - errorHandler.error(new ErrorEvent(e)); - } - } else { - if (errorHandler != null) { - errorHandler.error(new ErrorEvent(e)); + if (vaadinSession != null) { + vaadinSession.lock(); + } + try { + // if this was an UIDL request, response UIDL back to client + ErrorHandler errorHandler = ErrorEvent + .findErrorHandler(vaadinSession); + if (getRequestType(request) == RequestType.UIDL) { + SystemMessages ci = getService().getSystemMessages( + ServletPortletHelper.findLocale(null, vaadinSession, + request), request); + criticalNotification(request, response, + ci.getInternalErrorCaption(), + ci.getInternalErrorMessage(), null, + ci.getInternalErrorURL()); + if (errorHandler != null) { + errorHandler.error(new ErrorEvent(e)); + } } else { - // Re-throw other exceptions - throw new PortletException(e); + if (errorHandler != null) { + errorHandler.error(new ErrorEvent(e)); + } else { + // Re-throw other exceptions + throw new PortletException(e); + } + } + } finally { + if (vaadinSession != null) { + vaadinSession.unlock(); } } } diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 46fe3da5c6..bd379f94bc 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -512,26 +512,37 @@ public class VaadinServlet extends HttpServlet implements Constants { private void handleServiceException(VaadinServletRequest request, VaadinServletResponse response, VaadinSession vaadinSession, Throwable e) throws IOException, ServletException { - ErrorHandler errorHandler = ErrorEvent.findErrorHandler(vaadinSession); + if (vaadinSession != null) { + vaadinSession.lock(); + } + try { + ErrorHandler errorHandler = ErrorEvent + .findErrorHandler(vaadinSession); + + // if this was an UIDL request, response UIDL back to client + if (getRequestType(request) == RequestType.UIDL) { + SystemMessages ci = getService().getSystemMessages( + ServletPortletHelper.findLocale(null, vaadinSession, + request), request); + criticalNotification(request, response, + ci.getInternalErrorCaption(), + ci.getInternalErrorMessage(), null, + ci.getInternalErrorURL()); + if (errorHandler != null) { + errorHandler.error(new ErrorEvent(e)); + } + } else { + if (errorHandler != null) { + errorHandler.error(new ErrorEvent(e)); + } - // if this was an UIDL request, response UIDL back to client - if (getRequestType(request) == RequestType.UIDL) { - SystemMessages ci = getService().getSystemMessages( - ServletPortletHelper.findLocale(null, vaadinSession, - request), request); - criticalNotification(request, response, - ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), - null, ci.getInternalErrorURL()); - if (errorHandler != null) { - errorHandler.error(new ErrorEvent(e)); + // Re-throw other exceptions + throw new ServletException(e); } - } else { - if (errorHandler != null) { - errorHandler.error(new ErrorEvent(e)); + } finally { + if (vaadinSession != null) { + vaadinSession.unlock(); } - - // Re-throw other exceptions - throw new ServletException(e); } } |