Hi!
This just happened to me:
Exception in thread "xxx" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
at java.util.HashMap$ValueIterator.next(HashMap.java:822)
at name.pachler.nio.file.impl.BSDPathWatchService.pollImpl(BSDPathWatchService.java:386)
at name.pachler.nio.file.impl.BSDPathWatchService.take(BSDPathWatchService.java:281)
at xxx
at xxx
at java.lang.Thread.run(Thread.java:680)
I'm trying to recursively watch a directory tree (20 directories in total). I'm basically running this loop in a separate thread:
a) walk the tree, registering all directories for watching
b) watchService.take()
c) someEvent.notifyAll()
The other thread accessing watchService is when the bean is destroyed, I do a watchService.close(). But this did not happen here. I'm gonna dig into BSDWatchService and see if I find the error.
Kind regards,
Kosta
At first glance I find this rather puzzling. All access to the keys member of BSDPathWatchService is synchronized via the changeLock.
So this shoudln't be happening in another thread, which leaves concurrent modification in the for loop itself - and it doesn't look like that either.
Would be nice if you could isolate this into a unit test, so I can integrate it into the suite.
You could also test if this happens with 0.94 (I'm assuming you're using 0.95, are you?)
Cheers,
Uwe
View and moderate all "jpathwatch-issues Discussion" comments posted by this user
Mark all as spam, and block user from posting to "jpathwatch issues"
Yes, after looking through the BSDPathWatchService, I was puzzled, too. I could not find anything that could cause such an Exception.
Yes, I am using 0.95. I am currently working on a unit test to isolate this problem. I will let you know if I find anything.
View and moderate all "jpathwatch-issues Discussion" comments posted by this user
Mark all as spam, and block user from posting to "jpathwatch issues"
Ok, the problem was me not calling WatchKey.cancel() on a key that was deleted / moved elsewhere. Calling cancel() made the Exception disappear.
I can still create a unit test for you if you want. I am still puzzled where the ConcurrentModificationException came from.
Hi,
A unit test would be absolutely awesome, as you'd save me the trouble. Simply paste it here, I'll put it into JDK7Test.java and see what I can make out of it.
Thanks,
Uwe