avoid illegalstateexception

This commit is contained in:
zzz
2009-02-04 14:16:36 +00:00
parent 3d8cb3b90d
commit 5946c35a88

View File

@ -61,18 +61,26 @@ public class Shitlist {
} }
private class Cleanup extends JobImpl { private class Cleanup extends JobImpl {
private List<Hash> _toUnshitlist;
public Cleanup(RouterContext ctx) { public Cleanup(RouterContext ctx) {
super(ctx); super(ctx);
_toUnshitlist = new ArrayList(4);
getTiming().setStartAfter(ctx.clock().now() + SHITLIST_CLEANER_START_DELAY); getTiming().setStartAfter(ctx.clock().now() + SHITLIST_CLEANER_START_DELAY);
} }
public String getName() { return "Cleanup shitlist"; } public String getName() { return "Cleanup shitlist"; }
public void runJob() { public void runJob() {
_toUnshitlist.clear();
long now = getContext().clock().now(); long now = getContext().clock().now();
try {
for (Iterator iter = _entries.entrySet().iterator(); iter.hasNext(); ) { for (Iterator iter = _entries.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<Hash, Entry> e = (Map.Entry) iter.next(); Map.Entry<Hash, Entry> e = (Map.Entry) iter.next();
if (e.getValue().expireOn <= now) { if (e.getValue().expireOn <= now) {
iter.remove(); iter.remove();
Hash peer = e.getKey(); _toUnshitlist.add(e.getKey());
}
}
} catch (IllegalStateException ise) {} // next time...
for (Hash peer : _toUnshitlist) {
PeerProfile prof = _context.profileOrganizer().getProfile(peer); PeerProfile prof = _context.profileOrganizer().getProfile(peer);
if (prof != null) if (prof != null)
prof.unshitlist(); prof.unshitlist();
@ -80,7 +88,6 @@ public class Shitlist {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Unshitlisting router (expired) " + peer.toBase64()); _log.info("Unshitlisting router (expired) " + peer.toBase64());
} }
}
requeue(30*1000); requeue(30*1000);
} }