diff options
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()); } } |