Changeset 8549988


Ignore:
Timestamp:
Feb 13, 2011 8:36:43 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
289c7d6
Parents:
38bfca1
Message:
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r38bfca1 r8549988  
     12011-02-13 zzz
     2    * Connect Client: Minor NPE fix cleanup
     3    * JobQueue: Prevet NPE at shutdown (thanks liberty)
     4    * GeoIP: Prevent startup NPE (ticket #413, thanks RN)
     5    * NetDB: Prevent ExpireLeaseJob NPE (thanks sponge)
     6
    172011-02-11 Mathiasdm
    28    * routerconsole: fixed graphs using jrobin; and headless issue
  • router/java/src/net/i2p/router/RouterVersion.java

    r38bfca1 r8549988  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 9;
     21    public final static long BUILD = 10;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/networkdb/kademlia/ExpireLeasesJob.java

    r38bfca1 r8549988  
    1010
    1111import java.util.HashSet;
    12 import java.util.Iterator;
     12import java.util.Map;
    1313import java.util.Set;
    1414
     
    2828 */
    2929class ExpireLeasesJob extends JobImpl {
    30     private Log _log;
    31     private KademliaNetworkDatabaseFacade _facade;
     30    private final Log _log;
     31    private final KademliaNetworkDatabaseFacade _facade;
    3232   
    3333    private final static long RERUN_DELAY_MS = 1*60*1000;
     
    4040   
    4141    public String getName() { return "Expire Lease Sets Job"; }
     42
    4243    public void runJob() {
    43         Set toExpire = selectKeysToExpire();
     44        Set<Hash> toExpire = selectKeysToExpire();
    4445        _log.info("Leases to expire: " + toExpire);
    45         for (Iterator iter = toExpire.iterator(); iter.hasNext(); ) {
    46             Hash key = (Hash)iter.next();
     46        for (Hash key : toExpire) {
    4747            _facade.fail(key);
    4848            //_log.info("Lease " + key + " is expiring, so lets look for it again", new Exception("Expire and search"));
     
    5858     *
    5959     */
    60     private Set selectKeysToExpire() {
    61         Set keys = _facade.getDataStore().getKeys();
    62         Set toExpire = new HashSet(128);
    63         for (Iterator iter = keys.iterator(); iter.hasNext(); ) {
    64             Hash key = (Hash)iter.next();
    65             DatabaseEntry obj = _facade.getDataStore().get(key);
     60    private Set<Hash> selectKeysToExpire() {
     61        Set<Hash> toExpire = new HashSet(128);
     62        for (Map.Entry<Hash, DatabaseEntry> entry : _facade.getDataStore().getMapEntries()) {
     63            DatabaseEntry obj = entry.getValue();
    6664            if (obj.getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
    6765                LeaseSet ls = (LeaseSet)obj;
    6866                if (!ls.isCurrent(Router.CLOCK_FUDGE_FACTOR))
    69                     toExpire.add(key);
    70                 else
     67                    toExpire.add(entry.getKey());
     68                else if (_log.shouldLog(Log.DEBUG))
    7169                    _log.debug("Lease " + ls.getDestination().calculateHash() + " is current, no need to expire");
    7270            }
  • router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java

    r38bfca1 r8549988  
    1010
    1111import java.util.Collections;
    12 import java.util.Iterator;
    1312import java.util.Set;
    1413
     
    2928 */
    3029class ExpireRoutersJob extends JobImpl {
    31     private Log _log;
    32     private KademliaNetworkDatabaseFacade _facade;
     30    private final Log _log;
     31    private final KademliaNetworkDatabaseFacade _facade;
    3332   
    3433    /** rerun fairly often, so the fails don't queue up too many netdb searches at once */
     
    4241   
    4342    public String getName() { return "Expire Routers Job"; }
     43
    4444    public void runJob() {
    45         Set toExpire = selectKeysToExpire();
    46         _log.info("Routers to expire (drop and try to refetch): " + toExpire);
    47         for (Iterator iter = toExpire.iterator(); iter.hasNext(); ) {
    48             Hash key = (Hash)iter.next();
     45        // this always returns an empty set (see below)
     46        Set<Hash> toExpire = selectKeysToExpire();
     47        if (_log.shouldLog(Log.INFO))
     48            _log.info("Routers to expire (drop and try to refetch): " + toExpire);
     49        for (Hash key : toExpire) {
    4950            _facade.fail(key);
    5051        }
     
    6263     * @return nothing for now
    6364     */
    64     private Set selectKeysToExpire() {
    65         for (Iterator iter = _facade.getAllRouters().iterator(); iter.hasNext(); ) {
    66             Hash key = (Hash)iter.next();
     65    private Set<Hash> selectKeysToExpire() {
     66        for (Hash key : _facade.getAllRouters()) {
    6767            // Don't expire anybody we are connected to
    6868            if (!getContext().commSystem().isEstablished(key)) {
Note: See TracChangeset for help on using the changeset viewer.