Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.util.ConcurrentModificationException, debugging.

2 views
Skip to first unread message

Iain Toft

unread,
Sep 13, 2002, 10:46:56 PM9/13/02
to
Hi,
Is there an easy way to see which piece of code is doing the
'concurrent modification' when an
java.util.ConcurrentModificationException is thrown?

e.g.

java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:444)
at java.util.AbstractList$Itr.next(AbstractList.java:417)
at EnglishZIAgent.action(EnglishZIAgent.java:35)
at AuctionEntity$1.run(AuctionEntity.java:59)
at java.lang.Thread.run(Thread.java:536)

How can I find which piece of code is modifying my collection when
EnglishZIAgent.java:35 is called? It would be very handy for
debugging.

Some information...
EnglishZIAgent.java:35 is a Iterator.next() call. The collection on
which it is called is private member of the class and has no public
access through methods. The method action() is called as part of a
run() method (the EnglishZIAgent has its own thread).

Thanks,
Iain

Chris Smith

unread,
Sep 13, 2002, 11:06:08 PM9/13/02
to
Iain Toft wrote ...

> java.util.ConcurrentModificationException
> at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:444)
> at java.util.AbstractList$Itr.next(AbstractList.java:417)
> at EnglishZIAgent.action(EnglishZIAgent.java:35)
> at AuctionEntity$1.run(AuctionEntity.java:59)
> at java.lang.Thread.run(Thread.java:536)
>
> How can I find which piece of code is modifying my collection when
> EnglishZIAgent.java:35 is called? It would be very handy for
> debugging.

You could write a wrapper List implementation that logs all method calls
along with a stack trace, and then wrap the List in that.

Chris Smith

0 new messages