/** Indicates whether we timed out waiting for the invocation to run. */ @RunsInEDT private boolean postInvocationEvent(@Nonnull EventQueue eventQueue, long timeout) { Object lock = new RobotIdleLock(); synchronized (lock) { InvocationEvent event = new InvocationEvent(toolkit, EMPTY_RUNNABLE, lock, true); eventQueue.postEvent(event); long start = currentTimeMillis(); try { while (!event.isDispatched() && currentTimeMillis() - start < timeout) { lock.wait(timeout); } return (currentTimeMillis() - start) >= settings.idleTimeout(); } catch (InterruptedException e) { } return false; } }
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.aramco.ecc.licenseoptimizer.gui.Worker.run(Worker.java:23) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
/** Post a runnable on the given component's event queue. Useful when driving multiple Applets, but is also useful to ensure an operation happens on the event dispatch thread. */ public void invokeLater(Component context, Runnable action) { EventQueue queue = getEventQueue(context); queue.postEvent(new InvocationEvent(toolkit, action)); }
/** @return whether we timed out waiting for the invocation to run */ protected boolean postInvocationEvent(EventQueue eq, Toolkit toolkit, long timeout) { class RobotIdleLock { } Object lock = new RobotIdleLock(); synchronized(lock) { eq.postEvent(new InvocationEvent(toolkit, EMPTY_RUNNABLE, lock, true)); long start = System.currentTimeMillis(); try { // NOTE: on fast linux systems when showing a dialog, if we // don't provide a timeout, we're never notified, and the // test will wait forever (up through 1.5.0_05). lock.wait(timeout); return (System.currentTimeMillis() - start) >= IDLE_TIMEOUT; } catch(InterruptedException e) { Log.warn("Invocation lock interrupted"); throw new InterruptedAbbotException("Interrupted during invocation lock"); } } }
queue.postEvent(new InvocationEvent(toolkit, ft));