Re: ResultSet.previous() - ArrayIndexOutOfBoundsException

Lists: pgsql-jdbc
From: Fischer Krisztián <fischer(at)borganization(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: ResultSet.previous() - ArrayIndexOutOfBoundsException
Date: 2004-01-19 14:09:15
Message-ID: 400BE50B.9020303@borganization.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi!

I use PostgreSQL 7.4.1 through the shipped JDBC driver. In some
circumstances the driver throws the following exception:

[...]
java.lang.ArrayIndexOutOfBoundsException: 1 >= 0
at java.util.Vector.elementAt(Vector.java:431)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.previous(AbstractJdbc2ResultSet.java:495)
at
com.bh.server.implementation.SQLObject.previousRow(SQLObject.java:583)
at com.bh.server.implementation.DSF3.getBlock(DSF3.java:3916)
at
com.bh.server.implementation.DSF3.getPreviousBlock(DSF3.java:2302)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
[...]

I wrote a lot's of test, but i cannot reproduce the problem in a simple
form. However my real application (a quite huge one) produces the
exception above constantly. I guessed it's related to some
synchronization issue, but after making my ResultSet-wrapper object
thread safe, the problem still exists. So maybe it's a bug in the driver.

Has anyone such 'experiences'? Or some tips where do i mess it up?

Thanks in advance.

--
Fischer Krisztián <fischer(at)borganization(dot)com>
Tel: (+36)70/3843835, (+36)1/3360547
Borganization Kft.


From: Kris Jurka <books(at)ejurka(dot)com>
To: Fischer Krisztián <fischer(at)borganization(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: ResultSet.previous() - ArrayIndexOutOfBoundsException
Date: 2004-01-19 17:35:59
Message-ID: Pine.LNX.4.33.0401191232280.32357-200000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Mon, 19 Jan 2004, [ISO-8859-2] Fischer Krisztin wrote:

> Hi!
>
> I use PostgreSQL 7.4.1 through the shipped JDBC driver. In some
> circumstances the driver throws the following exception:
>
> [...]
> java.lang.ArrayIndexOutOfBoundsException: 1 >= 0
> at java.util.Vector.elementAt(Vector.java:431)
> at
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.previous(AbstractJdbc2ResultSet.java:495)
> at
> com.bh.server.implementation.SQLObject.previousRow(SQLObject.java:583)

Here's a sample program to demonstrate the problem. Basically it assumes
that rs.next() won't be called after it returns false. The same problem
is also true in reverse, calling previous and then next will show the same
issue. I should hopefully have a patch for this later today.

Kris Jurka

Attachment Content-Type Size
PreviousTest.java text/plain 532 bytes

From: Kris Jurka <books(at)ejurka(dot)com>
To: Fischer Krisztián <fischer(at)borganization(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: ResultSet.previous() - ArrayIndexOutOfBoundsException
Date: 2004-01-20 02:21:45
Message-ID: Pine.LNX.4.33.0401192119090.11604-200000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Mon, 19 Jan 2004, Kris Jurka wrote:

>
>
> On Mon, 19 Jan 2004, [ISO-8859-2] Fischer Krisztin wrote:
>
> > Hi!
> >
> > I use PostgreSQL 7.4.1 through the shipped JDBC driver. In some
> > circumstances the driver throws the following exception:
> >
> > [...]
> > java.lang.ArrayIndexOutOfBoundsException: 1 >= 0
> > at java.util.Vector.elementAt(Vector.java:431)
> > at
> > org.postgresql.jdbc2.AbstractJdbc2ResultSet.previous(AbstractJdbc2ResultSet.java:495)
> > at
> > com.bh.server.implementation.SQLObject.previousRow(SQLObject.java:583)
>
>
> Here's a sample program to demonstrate the problem. Basically it assumes
> that rs.next() won't be called after it returns false. The same problem
> is also true in reverse, calling previous and then next will show the same
> issue. I should hopefully have a patch for this later today.
>

I have applied a patch to fix this problem to the cvs version on gborg.
Here is the equivalent patch for the 7.4 series driver.

Kris Jurka

Attachment Content-Type Size
prevnext.patch text/plain 7.0 KB

From: Fischer Krisztián <fischer(at)borganization(dot)com>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: ResultSet.previous() - ArrayIndexOutOfBoundsException
Date: 2004-01-20 11:25:44
Message-ID: 400D1038.2000009@borganization.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Thanks for the fast response and for the patch Kris!

--
Fischer Krisztián <fischer(at)borganization(dot)com>
Tel: (+36)70/3843835, (+36)1/3360547
Borganization Kft.