You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shyama Gavulla <sh...@coe.neu.edu> on 2003/06/06 21:07:01 UTC
Clear User Session
--
Hi All,
I just moved my webapp from jrun to tomcat. I have a method which clears the
user session. The code snippet is
Enumeration session_var = session.getAttributeNames();
while(session_var.hasMoreElements())
{
String key=(String)session_var.nextElement();
I am getting an error here and the exception is
java.util.ConcurrentModificationException at
java.util.HashMap$HashIterator.nextEntry
How can I resolve this error.
Thanks a lot in advance
shyam
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Clear User Session
Posted by Tim Funk <fu...@joedog.org>.
Depending on who you talk to its a bug or not a bug in tomcat.
session.getAttributeNames() returns an Enumeration. Under the covers, the
Enumeration is actually a facade around an Iterator. Iterators are fail-fast
so if you are enumerating through session attributes and make changes, you
get the error as you have described.
The arguement is: is Enumeration allowed to be fail-fast?
In the meantime, 4.1 and 5 were patched to not make the Enumerator
originating from session.getAttributeNames be fail-fast.
As an aside - if you need to clear out a session: session.invalidate() is
much easier.
-Tim
Shyama Gavulla wrote:
> Hi All,
>
> I just moved my webapp from jrun to tomcat. I have a method which clears the
> user session. The code snippet is
>
> Enumeration session_var = session.getAttributeNames();
>
> while(session_var.hasMoreElements())
> {
> String key=(String)session_var.nextElement();
>
> I am getting an error here and the exception is
>
> java.util.ConcurrentModificationException at
> java.util.HashMap$HashIterator.nextEntry
>
> How can I resolve this error.
>
> Thanks a lot in advance
> shyam
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org