You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kent Kurima <nw...@hotmail.com> on 2002/02/19 16:51:14 UTC
ConcurrentModificationException error
When I try to remove some information from the session I get a
ConcurrentModificationException error.
tomcat 3.X did not have this problem, but tomcat 4.X is complaining about
this.
here is a section of code that is having the problem
java.util.Enumeration sessionNames = session.getAttributeNames();
while(sessionNames.hasMoreElements()){
String lstrSessionName = (String)sessionNames.nextElement();
if (!lvecTempVar.contains(lstrSessionName)) {
session.removeAttribute(lstrSessionName);
}
}
anyone have any ideas?
_________________________________________________________________
Join the worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>
Re: ConcurrentModificationException error
Posted by Eelco den Heijer <ee...@objectivation.com>.
Kent Kurima wrote:
>
> When I try to remove some information from the session I get a
> ConcurrentModificationException error.
>
> tomcat 3.X did not have this problem, but tomcat 4.X is complaining about
> this.
>
> here is a section of code that is having the problem
>
> java.util.Enumeration sessionNames = session.getAttributeNames();
> while(sessionNames.hasMoreElements()){
> String lstrSessionName = (String)sessionNames.nextElement();
> if (!lvecTempVar.contains(lstrSessionName)) {
> session.removeAttribute(lstrSessionName);
> }
Hi Kent,
Probably, another servlet instance is accessing that attr. of the
session; you have to synchronize access to it:
while(sessionNames.hasMoreElements()){
String lstrSessionName = (String)sessionNames.nextElement();
if (!lvecTempVar.contains(lstrSessionName)) {
synchronized (session) {
session.removeAttribute(lstrSessionName);
}
}
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>