/** 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; }
/** schedules the given expiration task */ public ExpiryTask addExpiryTask(ExpiryTask task) { LogWriterI18n log = task.getLocalRegion().getCache().getLoggerI18n(); try { if (DEBUG) { log.info(LocalizedStrings.ExpirationScheduler_SCHEDULING__0__TO_FIRE_IN__1__MS, new Object[] {task, Long.valueOf(task.getExpiryMillis())}); } // By using getExpirationTime and passing a Date to schedule // we get rid of two calls of System.currentTimeMillis(). // The Date object creation is very simple and has a very short life. timer.schedule(task, new Date(task.getExpirationTime())); } catch (EntryNotFoundException e) { // ignore - there are unsynchronized paths that allow an entry to // be destroyed out from under us. } catch (IllegalStateException e) { // task must have been cancelled by another thread so don't schedule it } return task; }