Re: ConcurrentModificationException in java.util.ServiceLoader (not a multi-thread issue)

2015-02-24 Thread Martin Desruisseaux
Hello Peter Le 24/02/15 13:49, Peter Levart a écrit : > You could synchronize on the entire loop and just copy over the > service objects to another collection (say ArrayList). Right, but I would like to keep the laziness instantiation behaviour. > If you really must combine laziness of constru

Re: ConcurrentModificationException in java.util.ServiceLoader (not a multi-thread issue)

2015-02-24 Thread Peter Levart
On 02/24/2015 10:32 AM, Martin Desruisseaux wrote: Le 24/02/15 09:09, Alan Bateman a écrit : Right, it has never supported multiple iterators but as it's an Iterable then it should unless specified otherwise. So I think this is a bug (although one could argue that the usage is unusual, almost a

Re: ConcurrentModificationException in java.util.ServiceLoader (not a multi-thread issue)

2015-02-24 Thread Martin Desruisseaux
Le 24/02/15 09:09, Alan Bateman a écrit : > Right, it has never supported multiple iterators but as it's an > Iterable then it should unless specified otherwise. So I think this is > a bug (although one could argue that the usage is unusual, almost a > mis-use). One use case is that in a multi-th

Re: ConcurrentModificationException in java.util.ServiceLoader (not a multi-thread issue)

2015-02-24 Thread Alan Bateman
On 24/02/2015 01:32, David Holmes wrote: On 24/02/2015 12:20 AM, Martin Desruisseaux wrote: Hello all java.util.ServiceLoader does not seem to support usage of a second Iterator in the middle of a previous iteration. Nope it doesn't. At a minimum this should be documented. The distinct Itera

Re: ConcurrentModificationException in java.util.ServiceLoader (not a multi-thread issue)

2015-02-23 Thread David Holmes
On 24/02/2015 12:20 AM, Martin Desruisseaux wrote: Hello all java.util.ServiceLoader does not seem to support usage of a second Iterator in the middle of a previous iteration. Nope it doesn't. At a minimum this should be documented. The distinct Iterator instances returned by iterator() share

ConcurrentModificationException in java.util.ServiceLoader (not a multi-thread issue)

2015-02-23 Thread Martin Desruisseaux
Hello all java.util.ServiceLoader does not seem to support usage of a second Iterator in the middle of a previous iteration. The attached Java file provides two simple tests with a ServiceLoader iterating over two elements. The first test creates two iterators and invokes their hasNext() / next()