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

Alan Bateman Alan.Bateman at oracle.com
Tue Feb 24 08:09:14 UTC 2015


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 
> Iterator instances returned by iterator() share the same lazy-lookup 
> iterator.
>
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). 
Not clear whether it's worth doing anything about it now, this is 
because ServiceLoader is going to change very significantly soon when it 
is re-specified to work with modules. I'll create a bug anyway to track 
it anyway.

-Alan.



More information about the core-libs-dev mailing list