question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Iterating over result of ShareServiceClient.listShares results in infinite loop

See original GitHub issue

Describe the bug Calling ShareServiceClient.listShares and iterating over the results endlessly loops over all shares.

To Reproduce

  • Set up an Azure Storage account
  • Add a limited amount of shares (e.g. two)
  • create a ShareServiceClient
  • call listShares on the client, and iterate over the result

Code Snippet Using stream()

ShareServiceClient azureClient = new ShareServiceClientBuilder()
        .connectionString(connectionString)
        .buildClient();
azureClient.listShares()
           .stream()
           .forEach(shareItem -> System.out.println("Share: " + shareItem.getName()));

Using the for-each construct:

for (ShareItem shareItem : azureClient.listShares()) {
    System.out.println("Share: " + shareItem.getName());
}

Using the paged functionality:

for (PagedResponse<ShareItem> page : azureClient.listShares().iterableByPage(100)) {
    for (ShareItem shareItem : page.getValue()) {
        System.out.println("Share:" + shareItem.getName());
    }
}

Expected behavior The name of each available share is printed once

Actual result: this keeps printing the same share names over and over, without ever stopping.

Setup (please complete the following information):

  • OS: Linux, macOS, Windows
  • IDE : IntelliJ, Eclipse, gradle, maven, …
  • Version of the Library used:
    • azure-storage-file-share : 12.8.0
    • azure-storage-common : 12.10.0
    • azure-core: 1.12.0

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gapra-msftcommented, Mar 16, 2021

This was recently fixed by the release of azure-core. We should transitively pick up the fix once we release our next version of storage

0reactions
willemvcommented, Apr 26, 2021

The issue is fixed in 12.9.0-beta.2 and later, thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does this method result in an infinite loop? - Stack Overflow
It looks like the Select is iterating over its own output. That's a little bit strange in itself, because typically an IEnumerable will...
Read more >
Loops in Java – Ultimate Guide - Funnel Garden
We'll cover how you loop over characters in a string, an array of strings, an array of integers, as well as iterating over...
Read more >
The Common Lisp Cookbook – Loop, iteration, mapping
Looping an infinite number of times, cycling over a circular list. First, as shown above, ... mapcar returns the results of the lambda...
Read more >
Why is this code not working ? Why does It stops looping
Loop's over everyone, let's move on! For a loop iteration to run it ONLY tests for the existence of a letter at the...
Read more >
VBA Loops - For, For Each, Do While and Do Until Loops
The Outer For Loop iterates over the variable 'sheet', and the Inner For Loop ... easy to make logical errors resulting in an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found