wolfie/SessionGuard — Issue #1: SessionGuard Out of Sync after component is removed
Author: johanneshayry
Created: 2011-11-23 12:42:08+00:00
State: open

The following code causes Out of Sync when session is near timeout

```Java
@Override
public void init() {
final Window mainWindow = new Window("Guard Application");
final SessionGuard guard1 = new SessionGuard();
guard1.setKeepalive(true);
final SessionGuard guard2 = new SessionGuard();
guard2.setKeepalive(true);
final Button doSwitch = new Button("Switch");
doSwitch.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
mainWindow.replaceComponent(guard1, guard2);
}
});
mainWindow.addComponent(guard1);
mainWindow.addComponent(doSwitch);
setMainWindow(mainWindow);
}
```

I'm guessing that when the widget is detached, the timer is not canceled so a changeVariables is called for already removed component.

Patch suggestion to VSessionGuard

```Java
@Override
protected void onDetach() {
super.onDetach();
timer.cancel();
}
```