File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -155,14 +155,18 @@ private MasterCleaner() {
155155 @ Override
156156 public void run () {
157157 long now ;
158+ long lastMasterRun = 0 ;
158159 while ((now = System .currentTimeMillis ()) < lastNonEmpty + MASTER_MAX_LINGER_MS || !deleteIfEmpty ()) {
159160 if (!cleanerImpls .isEmpty ()) { lastNonEmpty = now ; }
160161 try {
161162 Reference <?> ref = impl .referenceQueue .remove (MASTER_CLEANUP_INTERVAL_MS );
162163 if (ref instanceof CleanerRef ) {
163164 ((CleanerRef ) ref ).clean ();
164- } else {
165+ }
166+ // "now" is not really *now* at this point, but off by no more than MASTER_CLEANUP_INTERVAL_MS
167+ if (lastMasterRun + MASTER_CLEANUP_INTERVAL_MS <= now ) {
165168 masterCleanup ();
169+ lastMasterRun = now ;
166170 }
167171 } catch (InterruptedException ex ) {
168172 // Can be raised on shutdown. If anyone else messes with
You can’t perform that action at this time.
0 commit comments