@Override public void run() { List<Sweepable> refs = items.get(); if (refs == null) return; for (Sweepable sweepable : refs) { try { if (sweepable.sweep()) { refs.remove(sweepable); if (LOG.isDebugEnabled()) LOG.debug("Resource swept {}", sweepable); } } catch (Throwable x) { LOG.info("Exception while sweeping " + sweepable, x); } } activate(); }
if (((Sweeper.Sweepable)connection).sweep())
@Override public boolean sweep() { List<Connection> toSweep; lock(); try { toSweep = activeConnections.stream() .filter(connection -> connection instanceof Sweeper.Sweepable) .collect(Collectors.toList()); } finally { unlock(); } for (Connection connection : toSweep) { if (((Sweeper.Sweepable)connection).sweep()) { boolean removed = remove(connection, true); LOG.warn("Connection swept: {}{}{} from active connections{}{}", connection, System.lineSeparator(), removed ? "Removed" : "Not removed", System.lineSeparator(), dump()); } } return false; }
@Override public void run() { List<Sweepable> refs = items.get(); if (refs == null) return; for (Sweepable sweepable : refs) { try { if (sweepable.sweep()) { refs.remove(sweepable); if (LOG.isDebugEnabled()) LOG.debug("Resource swept {}", sweepable); } } catch (Throwable x) { LOG.info("Exception while sweeping " + sweepable, x); } } activate(); }
@Override public void run() { List<Sweepable> refs = items.get(); if (refs == null) return; for (Sweepable sweepable : refs) { try { if (sweepable.sweep()) { refs.remove(sweepable); if (LOG.isDebugEnabled()) LOG.debug("Resource swept {}", sweepable); } } catch (Throwable x) { LOG.info("Exception while sweeping " + sweepable, x); } } activate(); }