GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Iterator.next() is ignored for List<Value<T>> · Issue #993 · googleapis/google-cloud-java

Iterator.next() is ignored for List<Value<T>> #993

New issue
Copy link
New issue
Copy link
Closed
Closed
Iterator.next() is ignored for List<Value<T>>#993
Copy link
Assignees
ajkannan

Description

@volgin
volgin
opened on May 6, 2016
Issue body actions

This code produces an endless loop:

List<Value<Long>> releases = entity.getList("releases");
System.out.println(releases.size());    // prints 1 

while (releases.iterator().hasNext()) {
    Value<Long> value = releases.iterator().next();
    System.out.println(value.get());   // prints correct value over and over
}

Activity

  1. ajkannan commented on May 6, 2016

    @ajkannan
    ajkannan
    on May 6, 2016
    More actions

    The condition in the while loop creates a new iterator for each iteration of the loop, which causes the infinite loop. If you save the iterator you create before the while loop rather than creating a new one each time, the problem should be fixed.

  2. volgin commented on May 6, 2016

    @volgin
    volgin
    on May 6, 2016
    Author
    More actions

    Is this documented? Typically I don't expect a new iterator created when I simply pass a reference to it.

    -----Original Message-----
    From: "Ajay Kannan" [email protected]
    Sent: ‎5/‎6/‎2016 6:57 PM
    To: "GoogleCloudPlatform/gcloud-java" [email protected]
    Cc: "volgin" [email protected]; "Author" [email protected]
    Subject: Re: [GoogleCloudPlatform/gcloud-java] Iterator.next() is ignored forList<Value> (#993)

    The condition in the while loop creates a new iterator for each iteration of the loop, which causes the infinite loop. If you save the iterator you create before the while loop rather than creating a new one each time, the problem should be fixed.
    —
    You are receiving this because you authored the thread.
    Reply to this email directly or view it on GitHub

  3. ajkannan commented on May 6, 2016

    @ajkannan
    ajkannan
    on May 6, 2016
    More actions

    releases is of type java.util.List (which is Iterable). The contract of Iterable's iterator() is to return a new iterator over all items in the list. The code you provide would also loop endlessly if you used some other generic type (e.g. Integer), like below:

    List<Integer> releases = Collections.singletonList(1);
    System.out.println(releases.size());
    
    while (releases.iterator().hasNext()) {
        int value = releases.iterator().next();
        System.out.println(value);
    }
    
  4. volgin commented on May 6, 2016

    @volgin
    volgin
    on May 6, 2016
    Author
    More actions

    OK. Thank you for a quick response, and feel free to close this issue.

  5. ajkannan
    closed this as completedon May 6, 2016
  6. JustinBeckwith
    assigned
    ajkannan
    on Feb 1, 2021
  7. github-actions
    added a commit that references this issue on Jul 18, 2022

    build: marking dependencies (8) non-required (#1472) (#993)

    f97c3eb
  8. github-actions
    added a commit that references this issue on Sep 15, 2022

    chore(deps): update dependency com.google.cloud:google-cloud-dialogfl…

    251353e
  9. github-actions
    added 2 commits that reference this issue on Oct 4, 2022

    chore(main): release 0.124.14-SNAPSHOT (#993)

    8b20f7d

    chore(main): release 3.1.2 (#991)

    94431f9
  10. suztomo
    added a commit that references this issue on Feb 1, 2023

    chore(main): release 2.8.24-SNAPSHOT (#993)

    ee836fc
  11. meltsufin
    added a commit that references this issue on Dec 22, 2025

    deps: update dependency org.graalvm.buildtools:native-maven-plugin to…

    a94e428
  12. chingor13
    added a commit that references this issue on Jan 6, 2026

    deps: update dependency com.google.cloud:google-cloud-logging to v3.1…

    8bda6b7
  13. chingor13
    added 2 commits that reference this issue on Jan 22, 2026

    feat: OR query support (#993)

    99b7843

    chore(main): release 2.14.0 (#1014)

    a999a66
  14. chingor13
    added a commit that references this issue on Feb 24, 2026

    Fix: Not loosing the access token when calling UserCredentials#ToBuil… (

    84afdb8
  15. suztomo
    added a commit that references this issue on Mar 11, 2026

    deps: update dependency org.graalvm.buildtools:native-maven-plugin to…

    7905013
  16. chingor13
    added a commit that references this issue on Mar 12, 2026

    Fix: Not loosing the access token when calling UserCredentials#ToBuil… (

    068170e
  17. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore(main): release 0.124.16-SNAPSHOT (#993)

    2cffc1e
  18. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore(main): release 0.124.16-SNAPSHOT (#993)

    5f12cc5
  19. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore(java): update windows build (googleapis#993)

    92f71d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @ajkannan
    ajkannan

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.