Author: toad Date: 2008-03-24 16:41:52 +0000 (Mon, 24 Mar 2008) New Revision: 18741
Modified:
trunk/freenet/src/freenet/support/RandomGrabArray.java
Log:
Fix a doh in prev commit, and hopefully really fix the NPE
Modified: trunk/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArray.java 2008-03-24
16:40:08 UTC (rev 18740)
+++ trunk/freenet/src/freenet/support/RandomGrabArray.java 2008-03-24
16:41:52 UTC (rev 18741)
@@ -113,9 +113,11 @@
} else if(valid == 1) {
ret = reqs[validIndex];
if(ret.canRemove()) {
- index = 0;
contents.remove(ret);
-
reqs[validIndex] = null;
+ if(validIndex
!= index-1) {
+
reqs[validIndex] = reqs[index-1];
+ }
+ index--;
}
if(logMINOR)
Logger.minor(this, "No valid or excluded items after removing "+ret);
return ret;
@@ -128,11 +130,11 @@
ret = reqs[i];
if(ret == null) {
Logger.error(this, "reqs["+i+"] =
null");
- if(i == index-1) index--;
- else {
+ if(i != index-1) {
reqs[i] = reqs[index-1];
reqs[index] = null;
}
+ index--;
continue;
}
oret = ret;
