From e2e2b2c1e8acc2163d117dd8193b7ecc445f4ff8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 21 Jan 2013 21:52:00 +0200 Subject: [PATCH] Ensure window is closed even if close listener throws an exception (#10779) Change-Id: I58621c5f5ff01ccc96de3b602aac35f6fa01aa5b --- server/src/com/vaadin/ui/UI.java | 2 +- .../WindowWithInvalidCloseListener.html | 32 +++++++++++++++++ .../WindowWithInvalidCloseListener.java | 35 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html create mode 100644 uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 1babc077b8..7e54aa01a0 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -428,8 +428,8 @@ public abstract class UI extends AbstractSingleComponentContainer implements return false; } window.setParent(null); - window.fireClose(); markAsDirty(); + window.fireClose(); return true; } diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html new file mode 100644 index 0000000000..923276b613 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html @@ -0,0 +1,32 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.window.WindowWithInvalidCloseListener?restartApplication
mouseClickvaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]6,7
assertElementNotPresentvaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]
+ + diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java new file mode 100644 index 0000000000..991b5626eb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.java @@ -0,0 +1,35 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Window; +import com.vaadin.ui.Window.CloseEvent; +import com.vaadin.ui.Window.CloseListener; + +public class WindowWithInvalidCloseListener extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Window w = new Window("Close me"); + w.addCloseListener(new CloseListener() { + + @Override + public void windowClose(CloseEvent e) { + throw new RuntimeException( + "Close listener intentionally failed"); + } + }); + addWindow(w); + } + + @Override + protected String getTestDescription() { + return "The window has a close listener which throws an exception. This should not prevent the window from being closed."; + } + + @Override + protected Integer getTicketNumber() { + return 10779; + } + +} -- 2.39.5