----- Original Message -----
From: "Rickard �berg" <[EMAIL PROTECTED]>
To: "jBoss Developer" <[EMAIL PROTECTED]>
Sent: Wednesday, October 04, 2000 10:56 PM
Subject: Re: [jBoss-Dev] URL problem a JMX bug?


> Hey
>
> Aaron Mulder wrote:
> >         Download the JMX RI, and look at the source code for
> > com/sun/management/jmx/Introspector.java and in particular the for loop
> > that begins on line 386 and ends on line 397.  This is where it
generates
> > the attribute list (by combining entries for getters and setters).
> >         The logic here looks very sketchy to me - here's my pseudocode:
> >
> > for(i=0; i<vector.size(); i++) {
> >     ...
> >     if(readable and writeable) {
> >         vector.removeElementAt(i);
> >     }
> > }
> >
> >         To me, it looks like that will skip element i+1: when you remove
> > i, then i+1 becomes i, then you loop and increment to the new i+1 which
> > used to be i+2...
> >         Now, if i+1 happened to be setURL, it may get skipped, and bad
> > things could happen.
>
> Wow... they actually do that?! What a newbie bug *sigh*... yeah, that
> definitely is wrong. The right thing to do is make a copy and remove.

As far as I know you can also use an Iterator to do that like:
Iterator i = vector.iterator();
while( i.hasNext() ) {
    if( readable and writeable) {
        i.remove();
    }
}

>
> /Rickard
>
> --
> Rickard �berg
>
> Email: [EMAIL PROTECTED]
> http://www.telkel.com
> http://www.jboss.org
> http://www.dreambean.com
>
>


Reply via email to