From d2fb55ba41f7bd1d52cd54a3ce7e9cbec3cc6652 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 12 Sep 2012 11:53:55 +0300 Subject: [PATCH] Avoid infinite recursion in LegacyApplication.terminalError (#9581) --- server/src/com/vaadin/LegacyApplication.java | 6 +++--- .../com/vaadin/server/DefaultErrorListener.java | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/server/src/com/vaadin/LegacyApplication.java b/server/src/com/vaadin/LegacyApplication.java index ca9b196ff1..3a6ffaa39c 100644 --- a/server/src/com/vaadin/LegacyApplication.java +++ b/server/src/com/vaadin/LegacyApplication.java @@ -26,6 +26,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.vaadin.server.AbstractUIProvider; +import com.vaadin.server.DefaultErrorListener; import com.vaadin.server.Terminal.ErrorEvent; import com.vaadin.server.Terminal.ErrorListener; import com.vaadin.server.VaadinSession; @@ -105,8 +106,7 @@ public abstract class LegacyApplication extends AbstractUIProvider implements } @Override - public String getTheme(WrappedRequest request, - Class uiClass) { + public String getTheme(WrappedRequest request, Class uiClass) { return theme; } @@ -282,7 +282,7 @@ public abstract class LegacyApplication extends AbstractUIProvider implements @Override public void terminalError(ErrorEvent event) { - VaadinSession.getCurrent().getErrorHandler().terminalError(event); + DefaultErrorListener.doDefault(event); } public VaadinSession getContext() { diff --git a/server/src/com/vaadin/server/DefaultErrorListener.java b/server/src/com/vaadin/server/DefaultErrorListener.java index 46f96272fd..f007bdad63 100644 --- a/server/src/com/vaadin/server/DefaultErrorListener.java +++ b/server/src/com/vaadin/server/DefaultErrorListener.java @@ -26,11 +26,15 @@ import com.vaadin.ui.AbstractComponent; public class DefaultErrorListener implements Terminal.ErrorListener { @Override public void terminalError(ErrorEvent event) { + doDefault(event); + } + + public static void doDefault(ErrorEvent event) { final Throwable t = event.getThrowable(); if (t instanceof SocketException) { // Most likely client browser closed socket - getLogger() - .info("SocketException in CommunicationManager." + getLogger().info( + "SocketException in CommunicationManager." + " Most likely client (browser) closed socket."); return; } @@ -45,16 +49,15 @@ public class DefaultErrorListener implements Terminal.ErrorListener { // Shows the error in AbstractComponent if (owner instanceof AbstractComponent) { - ((AbstractComponent) owner) - .setComponentError(AbstractErrorMessage - .getErrorMessageForException(t)); + ((AbstractComponent) owner).setComponentError(AbstractErrorMessage + .getErrorMessageForException(t)); } // also print the error on console getLogger().log(Level.SEVERE, "Terminal error:", t); } - private Logger getLogger() { + private static Logger getLogger() { return Logger.getLogger(DefaultErrorListener.class.getName()); } } \ No newline at end of file -- 2.39.5