https://issues.apache.org/bugzilla/show_bug.cgi?id=51919

--- Comment #4 from Sebb <[email protected]> 2011-10-01 10:28:29 UTC ---
Cookies are currently stored in an ArrayList. The Javadoc says:

"If multiple threads access an ArrayList instance concurrently, and at least
one of the threads modifies the list structurally, it must be synchronized
externally."

This means that all accesses must be synchronised, not just modifications.

The simplest way to do this would be to use Collections.synchronizedList.

There is a concurrent list:

http://download.oracle.com/javase/6/docs/api/java/util/concurrent/CopyOnWriteArrayList.html

However this is only worth it if there are many more reads than writes.
I'm not sure that's the case with Cookies.

==

An alternative might be to somehow defer the cookie setting to the main sample
thread. It should not matter if the cookies are stored after all the resources
have been read, because the order of responses is not guaranteed. Any cookies
required by the resource download must exist before the request is made.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to