diff options
author | Per-Åke Minborg <minborg@speedment.com> | 2016-10-28 10:32:12 -0700 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2016-11-05 03:18:57 +0200 |
commit | 734d99d669e41855e57e491df612923bbaa731db (patch) | |
tree | 47fd487d9ffbd0bd323a638708080d81541db9cd /server/src | |
parent | d75b3a6380279bc04b764329cf9b8ccb486c430d (diff) | |
download | vaadin-framework-734d99d669e41855e57e491df612923bbaa731db.tar.gz vaadin-framework-734d99d669e41855e57e491df612923bbaa731db.zip |
Make sure lock() is released in finally block
Change-Id: I80b73b653e97904605dc62484a7448f3bfbf7227
Diffstat (limited to 'server/src')
2 files changed, 26 insertions, 21 deletions
diff --git a/server/src/test/java/com/vaadin/server/VaadinSessionTest.java b/server/src/test/java/com/vaadin/server/VaadinSessionTest.java index 58fb0658c5..0310b9293d 100644 --- a/server/src/test/java/com/vaadin/server/VaadinSessionTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinSessionTest.java @@ -156,8 +156,11 @@ public class VaadinSessionTest implements Serializable { // when we get here httpSessionLock.lock();// simulating servlet container's // session lock - mockService.fireSessionDestroy(session); - httpSessionLock.unlock(); + try { + mockService.fireSessionDestroy(session); + } finally { + httpSessionLock.unlock(); + } } catch (InterruptedException e) { throw new RuntimeException(e); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java index 429f6a838f..a2a25cb818 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java @@ -47,19 +47,21 @@ public class RemoveFromParentLockingTest { }; session.getLockInstance().lock(); + try { + UI ui = new UI() { + @Override + protected void init(VaadinRequest request) { + } + }; + ui.setSession(session); + + VerticalLayout layout = new VerticalLayout(); + ui.setContent(layout); + return layout; + } finally { + session.getLockInstance().unlock(); + } - UI ui = new UI() { - @Override - protected void init(VaadinRequest request) { - } - }; - ui.setSession(session); - - VerticalLayout layout = new VerticalLayout(); - ui.setContent(layout); - - session.getLockInstance().unlock(); - return layout; } @Test @@ -71,11 +73,11 @@ public class RemoveFromParentLockingTest { try { target.addComponent(testComponent); throw new AssertionError( - "Moving component when not holding its sessions's lock should throw"); + "Moving component when not holding its sessions's lock should throw"); } catch (IllegalStateException e) { Assert.assertEquals( - "Cannot remove from parent when the session is not locked.", - e.getMessage()); + "Cannot remove from parent when the session is not locked.", + e.getMessage()); } } @@ -104,12 +106,12 @@ public class RemoveFromParentLockingTest { try { lockedComponent.addComponent(notLockedComponent); throw new AssertionError( - "Moving component when not holding its sessions's lock should throw"); + "Moving component when not holding its sessions's lock should throw"); } catch (IllegalStateException e) { Assert.assertEquals( - "Cannot remove from parent when the session is not locked." - + " Furthermore, there is another locked session, indicating that the component might be about to be moved from one session to another.", - e.getMessage()); + "Cannot remove from parent when the session is not locked." + + " Furthermore, there is another locked session, indicating that the component might be about to be moved from one session to another.", + e.getMessage()); } } |