summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2013-10-09 15:31:06 +0300
committerVaadin Code Review <review@vaadin.com>2013-10-21 08:16:37 +0000
commitdd51b7f73062650cb3d5bb8550a0b088a0ea6595 (patch)
tree83488ef5ae0443b03dc645db1955ca278567953f /server
parented50200e9a68c00279cdefa65ccdccd4734d6c9a (diff)
downloadvaadin-framework-dd51b7f73062650cb3d5bb8550a0b088a0ea6595.tar.gz
vaadin-framework-dd51b7f73062650cb3d5bb8550a0b088a0ea6595.zip
Added more exception handling to PushHandler (#12578, #11882)
PushHandler now catches Exception and calls ErrorHandler more. Change-Id: I7032c00f717b1dae34f4352abc035b1b398c7cfc
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/communication/PushHandler.java50
1 files changed, 45 insertions, 5 deletions
diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java
index 81dd00084d..b7cc628856 100644
--- a/server/src/com/vaadin/server/communication/PushHandler.java
+++ b/server/src/com/vaadin/server/communication/PushHandler.java
@@ -31,6 +31,8 @@ import org.atmosphere.cpr.AtmosphereResourceEvent;
import org.atmosphere.cpr.AtmosphereResourceEventListenerAdapter;
import org.json.JSONException;
+import com.vaadin.server.ErrorEvent;
+import com.vaadin.server.ErrorHandler;
import com.vaadin.server.LegacyCommunicationManager.InvalidUIDLSecurityKeyException;
import com.vaadin.server.ServiceException;
import com.vaadin.server.ServletPortletHelper;
@@ -274,14 +276,52 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter
} else {
callback.run(resource, ui);
}
- } catch (IOException e) {
- getLogger().log(Level.WARNING, "Error writing a push response",
- e);
+ } catch (final IOException e) {
+ callErrorHandler(session, e);
+ } catch (final Exception e) {
+ SystemMessages msg = service.getSystemMessages(
+ ServletPortletHelper.findLocale(null, null,
+ vaadinRequest), vaadinRequest);
+ sendNotificationAndDisconnect(
+ resource,
+ VaadinService.createCriticalNotificationJSON(
+ msg.getInternalErrorCaption(),
+ msg.getInternalErrorMessage(), null,
+ msg.getInternalErrorURL()));
+ callErrorHandler(session, e);
} finally {
- session.unlock();
+ try {
+ session.unlock();
+ } catch (Exception e) {
+ getLogger().log(Level.WARNING,
+ "Error while unlocking session", e);
+ // can't call ErrorHandler, we (hopefully) don't have a lock
+ }
}
} finally {
- service.requestEnd(vaadinRequest, null, session);
+ try {
+ service.requestEnd(vaadinRequest, null, session);
+ } catch (Exception e) {
+ getLogger().log(Level.WARNING, "Error while ending request", e);
+
+ // can't call ErrorHandler, we don't have a lock
+ }
+ }
+ }
+
+ /**
+ * Call the session's {@link ErrorHandler}, if it has one, with the given
+ * exception wrapped in an {@link ErrorEvent}.
+ */
+ private void callErrorHandler(VaadinSession session, Exception e) {
+ try {
+ ErrorHandler errorHandler = ErrorEvent.findErrorHandler(session);
+ if (errorHandler != null) {
+ errorHandler.error(new ErrorEvent(e));
+ }
+ } catch (Exception ex) {
+ // Let's not allow error handling to cause trouble; log fails
+ getLogger().log(Level.WARNING, "ErrorHandler call failed", ex);
}
}