/** schedules the given expiration task */ public ExpiryTask addExpiryTask(ExpiryTask task) { try { if (logger.isTraceEnabled()) { logger.trace( LocalizedMessage.create( LocalizedStrings.ExpirationScheduler_SCHEDULING__0__TO_FIRE_IN__1__MS, new Object[] {task, Long.valueOf(task.getExpiryMillis())})); } // To fix bug 52267 do not create a Date here; instead calculate the relative duration. timer.schedule(task, task.getExpiryMillis()); } catch (EntryNotFoundException e) { // ignore - there are unsynchronized paths that allow an entry to // be destroyed out from under us. return null; } catch (IllegalStateException e) { // task must have been cancelled by another thread so don't schedule it return null; } return task; }
/** @see java.util.Timer#cancel() */ public void cancel() { timer.cancel(); }