Changeset 83480e4


Ignore:
Timestamp:
Jan 16, 2012 2:20:20 AM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
1591ddca
Parents:
da2cd92
Message:
  • NetDB: Hopefully fix rare NPE (ticket #589)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/kademlia/KBucketSet.java

    rda2cd92 r83480e4  
    2626 */
    2727class KBucketSet {
    28     private Log _log;
    29     private I2PAppContext _context;
    30     private LocalHash _us;
    31     private KBucket _buckets[];
     28    private final Log _log;
     29    private final I2PAppContext _context;
     30    private final LocalHash _us;
     31    private final KBucket _buckets[];
    3232    private volatile int _size;
    3333   
     
    4242        _context = context;
    4343        _log = context.logManager().getLog(KBucketSet.class);
    44         createBuckets();
     44        _buckets = createBuckets();
    4545        context.statManager().createRateStat("netDb.KBSGetAllTime", "Time to add all Hashes to the Collector", "NetworkDatabase", new long[] { 60*60*1000 });
    4646    }
     
    133133    public KBucket getBucket(int bucket) { return _buckets[bucket]; }
    134134   
    135     protected void createBuckets() {
    136         _buckets = new KBucket[NUM_BUCKETS];
     135    protected KBucket[] createBuckets() {
     136        KBucket[] buckets = new KBucket[NUM_BUCKETS];
    137137        for (int i = 0; i < NUM_BUCKETS-1; i++) {
    138             _buckets[i] = createBucket(i*BASE, (i+1)*BASE);
    139         }
    140         _buckets[NUM_BUCKETS-1] = createBucket(BASE*(NUM_BUCKETS-1), BASE*(NUM_BUCKETS) + 1);
     138            buckets[i] = createBucket(i*BASE, (i+1)*BASE);
     139        }
     140        buckets[NUM_BUCKETS-1] = createBucket(BASE*(NUM_BUCKETS-1), BASE*(NUM_BUCKETS) + 1);
     141        return buckets;
    141142    }
    142143   
Note: See TracChangeset for help on using the changeset viewer.