Apologies for sending to the wrong list, I've now subscribed to the dev 
one.

btw, this is not the first code-related thing I've posted in here, and 
I've not had much response.. is anyone doing anything with the stuff I 
send? Is there a better way to submit patches and changes? In future I 
was planning to post to -dev list, but if there's a better way than 
that....?

G.

On Tuesday, October 15, 2002, at 09:34  am, Gareth Boden wrote:

> Hi folks,
>
> Found a problem in LargeSelect - the list of results is passed using 
> ArrayList.sublist to the populateObjects() method, but in the meantime 
> results may still be being added to the list by a separate Thread, 
> which results in a ConcurrentModificationException.
>
> Need to construct a new ArrayList containing results to pass to 
> populateObjects(), and synchronize on returnResults when constructing 
> the new list or adding/removing from the main one.
>
> I might be wrong, but I think this patch is worthwhile:
>
> /usr/bin/cvs diff -w LargeSelect.java
> Index: LargeSelect.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-
> torque/src/java/org/apache/torque/util/LargeSelect.java,v
> retrieving revision 1.7
> diff -w -r1.7 LargeSelect.java
> 647c647,651
> <         List returnResults = results.subList(fromIndex, toIndex);
> ---
> >         List returnResults;
> >
> >         synchronized (results) {
> >             returnResults = new ArrayList(results.subList(fromIndex, 
> toIndex));
> >         }
> 718a723
> >                 synchronized (results) {
> 722a728
> >                 }
> 730a737
> >                     synchronized (results) {
> 731a739
> >                     }
>
> Gareth
>
---
Development Team Leader, eGS, 5-7 Singer Street, London EC2A 4BQ. +44 
(0)20 7336 1440

CONFIDENTIALITY: This is email is confidential and intended solely for 
the use of the individual to whom it is addressed.� Any views or 
opinions presented are solely those of the author and do not necessarily 
represent those of eGovernment Solutions (UK) Ltd.� If you are not the 
intended recipient, be advised that you have received this email in 
error and that any use, dissemination, forwarding, or copying of this 
email is strictly prohibited.� If you have received this email in error 
please contact the sender.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to