Changeset 289c7d6


Ignore:
Timestamp:
Feb 13, 2011 9:23:16 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
581cd72
Parents:
d15f682 (diff), 8549988 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge of 'b5d2a1759a243f1d66cec0bc09016324eb6e0286'

and 'dae0a00fe84fa6972a8c42237b2b57ec8e4d689d'

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java

    rd15f682 r289c7d6  
    171171                line = DataHelper.readLine(in);
    172172                if(line == null) {
    173                     line = ""; // prevent NPE, Is this what we need to do?
     173                    break;
    174174                }
    175175                line = line.trim();
  • history.txt

    rd15f682 r289c7d6  
     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/JobQueue.java

    rd15f682 r289c7d6  
    228228
    229229    public long getMaxLag() {
     230            // first job is the one that has been waiting the longest
    230231            Job j = _readyJobs.peek();
    231232            if (j == null) return 0;
    232             // first job is the one that has been waiting the longest
    233             long startAfter = j.getTiming().getStartAfter();
     233            JobTiming jt = j.getTiming();
     234            // PoisonJob timing is null, prevent NPE at shutdown
     235            if (jt == null)
     236                return 0;
     237            long startAfter = jt.getStartAfter();
    234238            return _context.clock().now() - startAfter;
    235239    }
  • router/java/src/net/i2p/router/RouterContext.java

    rd15f682 r289c7d6  
    77import net.i2p.I2PAppContext;
    88import net.i2p.data.Hash;
     9import net.i2p.data.RouterInfo;
    910import net.i2p.internal.InternalClientManager;
    1011import net.i2p.router.client.ClientManagerFacadeImpl;
     
    171172    /** what router is this context working for? */
    172173    public Router router() { return _router; }
    173     /** convenience method for querying the router's ident */
    174     public Hash routerHash() { return _router.getRouterInfo().getIdentity().getHash(); }
     174
     175    /**
     176     *  Convenience method for getting the router hash.
     177     *  Equivalent to context.router().getRouterInfo().getIdentity().getHash()
     178     *  @return may be null if called very early
     179     */
     180    public Hash routerHash() {
     181        if (_router == null)
     182            return null;
     183        RouterInfo ri = _router.getRouterInfo();
     184        if (ri == null)
     185            return null;
     186        return ri.getIdentity().getHash();
     187    }
    175188
    176189    /**
  • router/java/src/net/i2p/router/RouterVersion.java

    rd15f682 r289c7d6  
    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

    rd15f682 r289c7d6  
    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

    rd15f682 r289c7d6  
    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)) {
  • router/java/src/net/i2p/router/transport/GeoIP.java

    rd15f682 r289c7d6  
    1717
    1818import net.i2p.data.DataHelper;
     19import net.i2p.data.Hash;
    1920import net.i2p.router.RouterContext;
    2021import net.i2p.util.ConcurrentHashSet;
     
    252253    private void updateOurCountry() {
    253254        String oldCountry = _context.router().getConfigSetting(PROP_IP_COUNTRY);
    254         String country = _context.commSystem().getCountry(_context.routerHash());
     255        Hash ourHash = _context.routerHash();
     256        // we should always have a RouterInfo by now, but we had one report of an NPE here
     257        if (ourHash == null)
     258            return;
     259        String country = _context.commSystem().getCountry(ourHash);
    255260        if (country != null && !country.equals(oldCountry)) {
    256261            _context.router().setConfigSetting(PROP_IP_COUNTRY, country);
Note: See TracChangeset for help on using the changeset viewer.