diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-03-15 15:09:32 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-06-08 08:32:16 +0000 |
commit | 3a42436fc9ce52e9689adf7166a9c5698224ec40 (patch) | |
tree | 62bfb4c433c6bd7c61b486424994c81c15a2bc4f /server | |
parent | 5ae33b641eea02b647825b27c311d4116f3be838 (diff) | |
download | vaadin-framework-3a42436fc9ce52e9689adf7166a9c5698224ec40.tar.gz vaadin-framework-3a42436fc9ce52e9689adf7166a9c5698224ec40.zip |
Don't allow null view providers (#17028)
Change-Id: I5ce4885f19aaac2d4454b5a368f3e58453cf76f9
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/navigator/Navigator.java | 8 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java | 17 |
2 files changed, 24 insertions, 1 deletions
diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index 65b3fec488..bd2b5711f8 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -745,9 +745,15 @@ public class Navigator implements Serializable { * the requested view name is found. * * @param provider - * provider to register + * provider to register, not <code>null</code> + * @throws IllegalArgumentException + * if the provided view provider is <code>null</code> */ public void addProvider(ViewProvider provider) { + if (provider == null) { + throw new IllegalArgumentException( + "Cannot add a null view provider"); + } providers.add(provider); } diff --git a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java index ff6028648e..2c045d53fa 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java @@ -712,4 +712,21 @@ public class NavigatorTest extends TestCase { navigator.addView("view", view); navigator.navigateTo("view"); } + + public void testNullViewProvider() { + IMocksControl control = EasyMock.createControl(); + NavigationStateManager manager = control + .createMock(NavigationStateManager.class); + ViewDisplay display = control.createMock(ViewDisplay.class); + + // create navigator to test + Navigator navigator = createNavigator(manager, display); + + try { + navigator.addProvider(null); + fail("Should not be allowed to add a null view provider"); + } catch (IllegalArgumentException e) { + // Expected + } + } } |