twitter/util — pull request #34 by jdanbrown (2012-08-23 22:09:13+00:00)
Title: Fix ScheduledThreadPoolTimer.schedule(...).cancel()

ScheduledThreadPoolTimer.schedule passes a java.util.TimerTask to its ScheduledExecutorService which, when later cancelled, has no effect because ScheduledExecutorService doesn't pay attention to the cancellation status of a java.util.TimerTask because it thinks it only has a Runnable (which is a supertype of java.util.TimerTask).

JavaTimer.schedule does work properly because java.util.Timer knows to check java.util.TimerTask.state for cancellation.

ScheduledThreadPoolTimer.{doAt,doLater} also both work properly because Timer.doAt builds its own cancellation mechanism into the Future that it returns.