[jcifs] ConcurrentModification exception from SmbTransport using examples/SmbCrawler

Eric eglass1 at comcast.net
Tue Sep 30 08:48:36 EST 2003

> java.util.ConcurrentModificationException
>        at 
> java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:552)
>        at java.util.LinkedList$ListItr.next(LinkedList.java:488)
>        at jcifs.smb.SmbTransport.tryClose(SmbTransport.java:310)
>        at jcifs.smb.SmbTransport.run(SmbTransport.java:440)
>        at java.lang.Thread.run(Thread.java:534)

Try the attached; access to the sessions list in getSmbSession is 
synchronized on the SmbTransport instance, but the iteration in the 
tryClose method is unsynchronized.  If getSmbSession is called by one 
thread while the iteration in tryClose is open, the linked list will 
detect and throw this exception (Iterators are fail-fast).  The attached 
synchronizes the access to the sessions list in tryClose on the 
SmbTransport object.  Previously (in jCIFS 0.7.10 at least), the 
sessions list was implemented as a Vector and used the elements 
enumeration, which isn't fail-fast; the Iterator's behavior is more 
robust, as it guarantees deterministic results.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: transport.zip
Type: application/zip
Size: 7683 bytes
Desc: not available
Url : http://lists.samba.org/archive/jcifs/attachments/20030929/71094f16/transport.zip

More information about the jcifs mailing list