Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 712179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:49:10+00:00 2026-05-14T04:49:10+00:00

Is this a known issue? I had trouble finding any search results. When iterating

  • 0

Is this a known issue? I had trouble finding any search results.

When iterating over a ServiceLoader while an iteration already is in progress, the first iteration will be aborted. For example, assuming there are at least two implementations of Foo, the following code will fail with an AssertionError:

ServiceLoader<Foo> loader = ServiceLoader.load(Foo.class);
Iterator<Foo> iter1 = loader.iterator();
iter1.next();

Iterator<Foo> iter2 = loader.iterator();
while (iter2.hasNext()) {
    iter2.next();
}

assert iter1.hasNext();

This only seems to occur, if the second iterator really terminates. The code will succeed in this variation for example:

ServiceLoader<Foo> loader = ServiceLoader.load(Foo.class);
Iterator<Foo> iter1 = loader.iterator();
iter1.next();

Iterator<Foo> iter2 = loader.iterator();
iter2.next();

assert iter1.hasNext();

Is this a bug or a feature? :p

Is there a ticket for this already anywhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:49:11+00:00Added an answer on May 14, 2026 at 4:49 am

    This could be a bug. I think it is since iterator.next() invokes next() on same reference of a lazy iterator internally.
    This behavior violates “Principle of least astonishment”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this isn't a unique issue but I've not had much luck finding
This type of stuff drives me nuts. I'm having trouble finding the exact issue
Am I doing something wrong is this a known issue with the ASP.NET MVC
this is a known issue with ItemsControl although I couldn't find a solution :(
I know there is already a question about this but my issue is more
I've had a look around but can't seem to find any information on this.
I'm not sure if anyone else has had trouble with this. I'm trying to
have you had or known of anyone experiencing issues recently (this week) with creating
I just want to know if there is any known issue, or if I'm
I know this issue has been touched on here but I have not found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.