@Override public synchronized Collection<PendingConfirm> expire(Listener listener, long cutoffTime) { SortedMap<Long, PendingConfirm> pendingConfirmsForListener = this.pendingConfirms.get(listener); if (pendingConfirmsForListener == null) { return Collections.<PendingConfirm>emptyList(); } else { List<PendingConfirm> expired = new ArrayList<PendingConfirm>(); Iterator<Entry<Long, PendingConfirm>> iterator = pendingConfirmsForListener.entrySet().iterator(); while (iterator.hasNext()) { PendingConfirm pendingConfirm = iterator.next().getValue(); if (pendingConfirm.getTimestamp() < cutoffTime) { expired.add(pendingConfirm); iterator.remove(); CorrelationData correlationData = pendingConfirm.getCorrelationData(); if (correlationData != null && StringUtils.hasText(correlationData.getId())) { this.pendingReturns.remove(correlationData.getId()); // NOSONAR never null } } else { break; } } return expired; } }
@Override public synchronized Collection<PendingConfirm> expire(Listener listener, long cutoffTime) { SortedMap<Long, PendingConfirm> pendingConfirmsForListener = this.pendingConfirms.get(listener); if (pendingConfirmsForListener == null) { return Collections.<PendingConfirm>emptyList(); } else { List<PendingConfirm> expired = new ArrayList<PendingConfirm>(); Iterator<Entry<Long, PendingConfirm>> iterator = pendingConfirmsForListener.entrySet().iterator(); while (iterator.hasNext()) { PendingConfirm pendingConfirm = iterator.next().getValue(); if (pendingConfirm.getTimestamp() < cutoffTime) { expired.add(pendingConfirm); iterator.remove(); CorrelationData correlationData = pendingConfirm.getCorrelationData(); if (correlationData != null && StringUtils.hasText(correlationData.getId())) { this.pendingReturns.remove(correlationData.getId()); // NOSONAR never null } } else { break; } } return expired; } }