diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-07 14:57:53 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-07 14:59:13 +0300 |
commit | 9f6bceab2861e4d5a8bccca6c2283804def6477c (patch) | |
tree | c5857443996b2211f11d95eb1ae3f98bd70f30f4 /uitest | |
parent | e954dec24903ec259aa4ef1d1d88555dfb8d3ac4 (diff) | |
download | vaadin-framework-9f6bceab2861e4d5a8bccca6c2283804def6477c.tar.gz vaadin-framework-9f6bceab2861e4d5a8bccca6c2283804def6477c.zip |
Use dedicated Lock for session synchronization (#9156)
Diffstat (limited to 'uitest')
4 files changed, 32 insertions, 12 deletions
diff --git a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java index 3adb284f1b..688b2ea4f5 100644 --- a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java @@ -34,8 +34,11 @@ public class ThreadLocalInstances extends AbstractTestCase { Thread thread = new Thread() { @Override public void run() { - synchronized (ThreadLocalInstances.this) { + getSession().getLock().lock(); + try { reportCurrentStatus("background thread"); + } finally { + getSession().getLock().unlock(); } } }; diff --git a/uitest/src/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java b/uitest/src/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java index a9d5869e5f..44fc77d142 100644 --- a/uitest/src/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java +++ b/uitest/src/com/vaadin/tests/components/table/RowUpdateShouldRetainContextMenu.java @@ -36,8 +36,11 @@ public class RowUpdateShouldRetainContextMenu extends TestBase { sleep(1000); } catch (InterruptedException ie) { } - synchronized (RowUpdateShouldRetainContextMenu.this) { + getContext().getLock().lock(); + try { indicator.setValue(progress += 0.01); + } finally { + getContext().getLock().unlock(); } } } diff --git a/uitest/src/com/vaadin/tests/components/table/TableFirstRowFlicker.java b/uitest/src/com/vaadin/tests/components/table/TableFirstRowFlicker.java index 5d36b8381b..f937ba6ed5 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableFirstRowFlicker.java +++ b/uitest/src/com/vaadin/tests/components/table/TableFirstRowFlicker.java @@ -43,7 +43,8 @@ public class TableFirstRowFlicker extends LegacyApplication { @Override public void run() { while (t != null) { - synchronized (t.getUI().getSession()) { + t.getUI().getSession().getLock().lock(); + try { int firstId = t.getCurrentPageFirstItemIndex(); Object selected = t.getValue(); t.setContainerDataSource(buildContainer()); @@ -51,6 +52,8 @@ public class TableFirstRowFlicker extends LegacyApplication { t.setCurrentPageFirstItemIndex(firstId); // lighter alternative for all of above // t.refreshRowCache(); + } finally { + t.getUI().getSession().getLock().unlock(); } try { Thread.sleep(500); diff --git a/uitest/src/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java b/uitest/src/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java index 3a07a89302..f3bd903686 100644 --- a/uitest/src/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java +++ b/uitest/src/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java @@ -46,13 +46,18 @@ public class MassInsertMemoryLeakTestApp extends LegacyApplication { private class MassInsert extends Thread { @Override - public synchronized void start() { - proggress.setVisible(true); - proggress.setValue(new Float(0)); - proggress.setPollingInterval(100); - process.setEnabled(false); - proggress.setCaption(""); - super.start(); + public void start() { + getContext().getLock().lock(); + try { + proggress.setVisible(true); + proggress.setValue(new Float(0)); + proggress.setPollingInterval(100); + process.setEnabled(false); + proggress.setCaption(""); + super.start(); + } finally { + getContext().getLock().unlock(); + } } @Override @@ -73,11 +78,14 @@ public class MassInsertMemoryLeakTestApp extends LegacyApplication { getRandonName()); } c.commit(); - synchronized (MassInsertMemoryLeakTestApp.this) { + getContext().getLock().lock(); + try { proggress .setValue(new Float((1.0f * cent) / cents)); proggress.setCaption("" + 100 * cent + " rows inserted"); + } finally { + getContext().getLock().unlock(); } } } catch (SQLException e) { @@ -87,10 +95,13 @@ public class MassInsertMemoryLeakTestApp extends LegacyApplication { e.printStackTrace(); } } - synchronized (MassInsertMemoryLeakTestApp.this) { + getContext().getLock().lock(); + try { proggress.setVisible(false); proggress.setPollingInterval(0); process.setEnabled(true); + } finally { + getContext().getLock().unlock(); } } } |