You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OutOfSync.java 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.vaadin.tests.components;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.ui.Button.ClickEvent;
  5. import com.vaadin.ui.Button.ClickListener;
  6. import com.vaadin.ui.Notification;
  7. public class OutOfSync extends AbstractTestUI {
  8. @Override
  9. protected void setup(VaadinRequest request) {
  10. Button b = new Button("Click me after 1s to be out of sync");
  11. b.addClickListener(new ClickListener() {
  12. @Override
  13. public void buttonClick(ClickEvent event) {
  14. Notification.show("This code will never be reached");
  15. }
  16. });
  17. setContent(b);
  18. Thread t = new Thread(new Runnable() {
  19. @Override
  20. public void run() {
  21. try {
  22. Thread.sleep(500);
  23. } catch (InterruptedException e) {
  24. e.printStackTrace();
  25. }
  26. // Remove button but prevent repaint -> causes out of sync
  27. // issues
  28. getSession().lock();
  29. try {
  30. setContent(null);
  31. getConnectorTracker().markClean(OutOfSync.this);
  32. } finally {
  33. getSession().unlock();
  34. }
  35. }
  36. });
  37. t.start();
  38. }
  39. @Override
  40. protected String getTestDescription() {
  41. return "Click the button after 1s when it has been removed server side (causing synchronization problems)";
  42. }
  43. @Override
  44. protected Integer getTicketNumber() {
  45. return 10780;
  46. }
  47. }