You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Krygowski <ja...@shaws.com> on 2002/11/14 17:31:54 UTC

IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1

Hi all-

we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03
that was working fine.  Recently, we've been given the signal to upgrade to
J2SDK 1.4.1.  Fine, but now we're finding that our form posts are failing
with IndexOutOfBoundsException.  I've traced through the Struts source with
a debugger and found the problem in this block of PropertyUtils code:

        // Call the property getter and return the value
        Object value = readMethod.invoke(bean, new Object[0]);
        if (!value.getClass().isArray()) {
            if (!(value instanceof java.util.List)) {
                throw new IllegalArgumentException("Property '" + name
                        + "' is not indexed");
            } else {
                //get the List's value
                return ((java.util.List) value).get(index);
            }
        } else {
            //get the array's value
            return (Array.get(value, index));
        }

It seems to me that the line:

return ((java.util.List) value).get(index)

fails because the form bean just got created by Struts and hasn't been
populated yet.  However, it works just fine when I switch back to JDK 1.3.1.

Anyone got any suggestions as to what might be happening?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1

Posted by Jim Krygowski <ja...@shaws.com>.
Been doing some research since my last post.  Here's the setup, same
application code, same struts jars, same app server switching between JDK
1.3.1 and 1.4.1:

When processing a submit, in the PropertyUtils the following check is made
in the getIndexedProperty method on or around line 468:

 if (descriptor instanceof IndexedPropertyDescriptor) {

With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor,
but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes
by the block that should handle the property I've passed an onto a block of
code that results in the IndexOutOfBoundsException.

This seems like a 1.4.1 induced bug.  Should I log it in Bugzilla?  Has
anyone else seen this bug?



> -----Original Message-----
> From: Jim Krygowski [mailto:james.krygowski@shaws.com]
> Sent: Thursday, November 14, 2002 11:32 AM
> To: Struts Users Mailing List
> Subject: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
>
>
> Hi all-
>
> we have an application originally written to struts 1.1b2 and
> J2SDK 1.3.1_03
> that was working fine.  Recently, we've been given the signal to
> upgrade to
> J2SDK 1.4.1.  Fine, but now we're finding that our form posts are failing
> with IndexOutOfBoundsException.  I've traced through the Struts
> source with
> a debugger and found the problem in this block of PropertyUtils code:
>
>         // Call the property getter and return the value
>         Object value = readMethod.invoke(bean, new Object[0]);
>         if (!value.getClass().isArray()) {
>             if (!(value instanceof java.util.List)) {
>                 throw new IllegalArgumentException("Property '" + name
>                         + "' is not indexed");
>             } else {
>                 //get the List's value
>                 return ((java.util.List) value).get(index);
>             }
>         } else {
>             //get the array's value
>             return (Array.get(value, index));
>         }
>
> It seems to me that the line:
>
> return ((java.util.List) value).get(index)
>
> fails because the form bean just got created by Struts and hasn't been
> populated yet.  However, it works just fine when I switch back to
> JDK 1.3.1.
>
> Anyone got any suggestions as to what might be happening?
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>