Check for system time jump back (logging only)

This commit is contained in:
Vassiliy.Kudryashov
2016-12-26 17:30:49 +03:00
parent 94daf229e6
commit cf3c645623
@@ -114,6 +114,7 @@ public class IdeEventQueue extends EventQueue {
private boolean myIsInInputEvent;
private AWTEvent myCurrentEvent;
private long myLastActiveTime;
private long myLastEventTime = System.currentTimeMillis();
private WindowManagerEx myWindowManager;
private final List<EventDispatcher> myDispatchers = ContainerUtil.createLockFreeCopyOnWriteList();
private final List<EventDispatcher> myPostProcessors = ContainerUtil.createLockFreeCopyOnWriteList();
@@ -338,6 +339,7 @@ public class IdeEventQueue extends EventQueue {
@Override
public void dispatchEvent(@NotNull AWTEvent e) {
checkForTimeJump();
if (!appIsLoaded()) {
try {
super.dispatchEvent(e);
@@ -382,6 +384,15 @@ public class IdeEventQueue extends EventQueue {
}
}
//As we rely on system time monotonicity in many places let's log anomalies at least.
private void checkForTimeJump() {
long now = System.currentTimeMillis();
if (myLastEventTime > now + 1000) {
LOG.error("System clock's jumped back by ~" + (myLastEventTime - now) / 1000 + " sec");
}
myLastEventTime = now;
}
private static boolean isInputEvent(@NotNull AWTEvent e) {
return e instanceof InputEvent || e instanceof InputMethodEvent || e instanceof WindowEvent || e instanceof ActionEvent;
}