diff options
-rw-r--r-- | server/src/main/java/com/vaadin/server/Page.java | 21 | ||||
-rw-r--r-- | server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java | 1 |
2 files changed, 17 insertions, 5 deletions
diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java index 925df59121..2a0c8ab83e 100644 --- a/server/src/main/java/com/vaadin/server/Page.java +++ b/server/src/main/java/com/vaadin/server/Page.java @@ -996,11 +996,22 @@ public class Page implements Serializable { * set to {@code false} */ public URI getLocation() throws IllegalStateException { - if (location == null && !uI.getSession().getConfiguration() - .isSendUrlsAsParameters()) { - throw new IllegalStateException("Location is not available as the " - + Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS - + " parameter is configured as false"); + if (location == null) { + if (uI.getSession() != null && !uI.getSession().getConfiguration() + .isSendUrlsAsParameters()) { + throw new IllegalStateException("Location is not available as the " + + Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS + + " parameter is configured as false"); + } else if (VaadinSession.getCurrent() == null) { + throw new IllegalStateException("Location is not available as the " + + Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS + + " parameter state cannot be determined"); + } else if (!VaadinSession.getCurrent().getConfiguration() + .isSendUrlsAsParameters()) { + throw new IllegalStateException("Location is not available as the " + + Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS + + " parameter is configured as false"); + } } return location; } diff --git a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java index 66f3dca4c5..9d68aca898 100644 --- a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java +++ b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java @@ -54,6 +54,7 @@ public class ServletUIInitHandlerTest { session); session.setCommunicationManager(communicationManager); session.setConfiguration(deploymentConfiguration); + session.setCurrent(session); session.addUIProvider(new UIProvider() { @Override |