List Info

Thread: ArrayIndexOutOfBoundsException in CookieSpecBase




ArrayIndexOutOfBoundsException in CookieSpecBase
user name
2006-11-02 18:23:57
I wonder if anyone has any hints for me....I'm getting this
exception every so often (every 100 or so runs):

java.lang.ArrayIndexOutOfBoundsException: 1
	at java.util.LinkedList.toArray(LinkedList.java:657)
	at
org.apache.commons.httpclient.cookie.CookieSpecBase.match(Co
okieSpecBase.java:564)
	at
org.apache.commons.httpclient.HttpMethodBase.addCookieReques
tHeader(HttpMethodBase.java:1179)
	at
org.apache.commons.httpclient.HttpMethodBase.addRequestHeade
rs(HttpMethodBase.java:1305)
	at
org.apache.commons.httpclient.HttpMethodBase.writeRequestHea
ders(HttpMethodBase.java:2036)
	at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(Ht
tpMethodBase.java:1919)
	at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMet
hodBase.java:993)
	at
org.apache.commons.httpclient.HttpMethodDirector.executeWith
Retry(HttpMethodDirector.java:397)
	at
org.apache.commons.httpclient.HttpMethodDirector.executeMeth
od(HttpMethodDirector.java:170)
	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpC
lient.java:396)
	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpC
lient.java:324)
         <my code snipped>

This is with HttpClient 3.0.1. I've seen this one at least
two platforms (windows and linux). I know it happens with 
1.4.2, not sure about 1.5. I'm only testing with Sun VMs.

The strange thing is that the code in CookieSpecBase looks
like it can never produce this exception (since the 
LinkedList in question is local, and this isn't being
modified by another thread).

Am I reading that code right? Any ideas what the heck can be
going on? I don't suspect a bug in httpclient.

Link to the source I'm referring to
http://svn.apache.org/viewvc/jakarta/commons/prope
r/httpclient/tags/HTTPCLIENT_3_0_1/src/java/org/apache/commo
ns/httpclient/cookie/CookieSpecBase.java?revision=404763&
;view=markup

thanks in advance
-tim


------------------------------------------------------------
---------
To unsubscribe, e-mail: httpclient-dev-unsubscribejakarta.apache.org
For additional commands, e-mail: httpclient-dev-helpjakarta.apache.org

ArrayIndexOutOfBoundsException in CookieSpecBase
user name
2006-11-02 18:53:07
On Thu, 2006-11-02 at 10:23 -0800, Tim Eck wrote:
> I wonder if anyone has any hints for me....I'm getting
this exception every so often (every 100 or so runs):
> 
> java.lang.ArrayIndexOutOfBoundsException: 1
> 	at java.util.LinkedList.toArray(LinkedList.java:657)
> 	at
org.apache.commons.httpclient.cookie.CookieSpecBase.match(Co
okieSpecBase.java:564)
> 	at
org.apache.commons.httpclient.HttpMethodBase.addCookieReques
tHeader(HttpMethodBase.java:1179)
> 	at
org.apache.commons.httpclient.HttpMethodBase.addRequestHeade
rs(HttpMethodBase.java:1305)
> 	at
org.apache.commons.httpclient.HttpMethodBase.writeRequestHea
ders(HttpMethodBase.java:2036)
> 	at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(Ht
tpMethodBase.java:1919)
> 	at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMet
hodBase.java:993)
> 	at
org.apache.commons.httpclient.HttpMethodDirector.executeWith
Retry(HttpMethodDirector.java:397)
> 	at
org.apache.commons.httpclient.HttpMethodDirector.executeMeth
od(HttpMethodDirector.java:170)
> 	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpC
lient.java:396)
> 	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpC
lient.java:324)
>          <my code snipped>
> 
> This is with HttpClient 3.0.1. I've seen this one at
least two platforms (windows and linux). I know it happens
with 
> 1.4.2, not sure about 1.5. I'm only testing with Sun
VMs.
> 
> The strange thing is that the code in CookieSpecBase
looks like it can never produce this exception (since the 
> LinkedList in question is local, and this isn't being
modified by another thread).
> 
> Am I reading that code right? Any ideas what the heck
can be going on? I don't suspect a bug in httpclient.
> 

Tim,

I do not see how possibly HttpClient could be causing
LinkedList#toArray
to throw an ArrayIndexOutOfBoundsException exception in this
case. 

In this particular case I am more inclined to suspect a bug
in Sun's
Java Runtime Library. If you knew what cookies HttpClient
was trying to
match against which target host, I might be able to
reproduce the
problem locally.

Oleg

> Link to the source I'm referring to
> http://svn.apache.org/viewvc/jakarta/commons/prope
r/httpclient/tags/HTTPCLIENT_3_0_1/src/java/org/apache/commo
ns/httpclient/cookie/CookieSpecBase.java?revision=404763&
;view=markup
> 
> thanks in advance
> -tim
> 
> 
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: httpclient-dev-unsubscribejakarta.apache.org
> For additional commands, e-mail:
httpclient-dev-helpjakarta.apache.org
> 
> 


------------------------------------------------------------
---------
To unsubscribe, e-mail: httpclient-dev-unsubscribejakarta.apache.org
For additional commands, e-mail: httpclient-dev-helpjakarta.apache.org

ArrayIndexOutOfBoundsException in CookieSpecBase
user name
2006-11-04 09:25:23

Oleg Kalnichevski wrote:
> Tim,
> 
> I do not see how possibly HttpClient could be causing
LinkedList#toArray
> to throw an ArrayIndexOutOfBoundsException exception in
this case. 
> 
> In this particular case I am more inclined to suspect a
bug in Sun's
> Java Runtime Library. If you knew what cookies
HttpClient was trying to
> match against which target host, I might be able to
reproduce the
> problem locally.
> 
> Oleg

It could be a concurrency problem. Call toArray while
modifiying the
list and it may happen?

Just an idea

Odi

------------------------------------------------------------
---------
To unsubscribe, e-mail: httpclient-dev-unsubscribejakarta.apache.org
For additional commands, e-mail: httpclient-dev-helpjakarta.apache.org

ArrayIndexOutOfBoundsException in CookieSpecBase
user name
2006-11-04 11:53:26
On Sat, 2006-11-04 at 10:25 +0100, Ortwin Glück wrote:
> 
> Oleg Kalnichevski wrote:
> > Tim,
> > 
> > I do not see how possibly HttpClient could be
causing LinkedList#toArray
> > to throw an ArrayIndexOutOfBoundsException
exception in this case. 
> > 
> > In this particular case I am more inclined to
suspect a bug in Sun's
> > Java Runtime Library. If you knew what cookies
HttpClient was trying to
> > match against which target host, I might be able
to reproduce the
> > problem locally.
> > 
> > Oleg
> 
> It could be a concurrency problem. Call toArray while
modifiying the
> list and it may happen?
> 
> Just an idea
> 

Odi,

A race condition would have been the most likely
explanation, but the
LinkedList instance in question is method local

Oleg


> Odi
> 
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: httpclient-dev-unsubscribejakarta.apache.org
> For additional commands, e-mail:
httpclient-dev-helpjakarta.apache.org
> 
> 


------------------------------------------------------------
---------
To unsubscribe, e-mail: httpclient-dev-unsubscribejakarta.apache.org
For additional commands, e-mail: httpclient-dev-helpjakarta.apache.org

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )