On Tue, Apr 15, 2008 at 6:05 AM, Matthew Toseland
<toad at amphibian.dyndns.org> wrote:
>
> On Monday 14 April 2008 07:21, nextgens at freenetproject.org wrote:
>  > Author: nextgens
>  > Date: 2008-04-14 06:21:05 +0000 (Mon, 14 Apr 2008)
>  > New Revision: 19304
>  >
>  > Modified:
>  >    trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
>  >    trunk/freenet/src/freenet/keys/ClientCHKBlock.java
>  >    trunk/freenet/src/freenet/keys/FreenetURI.java
>  >    trunk/freenet/src/freenet/node/FailureTable.java
>  >    trunk/freenet/src/freenet/node/PeerManager.java
>  >    trunk/freenet/src/freenet/node/PeerNode.java
>  >    trunk/freenet/src/freenet/support/LoggerHookChain.java
>  >    trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
>  > Log:
>  > some paranoia code to prevent race conditions and out-of-bound exceptions
>  >
>  > Modified: 
> trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
>  > ===================================================================
>  > --- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
>  2008-04-14 05:28:57 UTC (rev 19303)
>  > +++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
>  2008-04-14 06:21:05 UTC (rev 19304)
>  > @@ -531,10 +531,11 @@
>  >                               }
>  >                       } else {
>  >                               SendableGet[] gets = (SendableGet[]) o;
>  > -                             SendableGet[] newGets = new 
> SendableGet[gets.length-1];
>  > +                             final int getsLength = gets.length;
>  > +                             SendableGet[] newGets = new 
> SendableGet[getsLength > 1 ? getsLength-1 :
>  0];
>
>  If gets.length == 0 then handle that properly please. But IMHO it shouldn't
>  happen.
>
>
>  >                               boolean found = false;
>  >                               int x = 0;
>  > -                             for(int j=0;j<gets.length;j++) {
>  > +                             for(int j=0;j<getsLength;j++) {
>
>  Congratulations, your pointless paranoia code has just introduced a real live
>  ArrayIndexOutOfBoundsException! For extra points, tell me where!
>

It don't. Size of arrays, unlike List/Vector, won't change.
(I *do* think this code is ugly and unnesssorary.)

Regard,
Cheng

Reply via email to