Author: toad
Date: 2008-03-24 16:40:08 +0000 (Mon, 24 Mar 2008)
New Revision: 18740

Modified:
   trunk/freenet/src/freenet/support/RandomGrabArray.java
Log:
Turn NPE into an error.

Modified: trunk/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArray.java      2008-03-24 
16:34:57 UTC (rev 18739)
+++ trunk/freenet/src/freenet/support/RandomGrabArray.java      2008-03-24 
16:40:08 UTC (rev 18740)
@@ -126,6 +126,15 @@
                                }
                                int i = rand.nextInt(index);
                                ret = reqs[i];
+                               if(ret == null) {
+                                       Logger.error(this, "reqs["+i+"] = 
null");
+                                       if(i == index-1) index--;
+                                       else {
+                                               reqs[i] = reqs[index-1];
+                                               reqs[index] = null;
+                                       }
+                                       continue;
+                               }
                                oret = ret;
                                if(ret.isCancelled()) {
                                        if(logMINOR) Logger.minor(this, "Not 
returning because cancelled: "+ret);


Reply via email to