-
Notifications
You must be signed in to change notification settings - Fork 743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java] Intermittent java.util.NoSuchElementException when listing all paged items. #1309
Comments
I can't reproduce this. The only possible scenario I can think of that can cause this is a |
Yes, the client should be resilient to empty list, returned by service instead of throwing exception.. |
I think the previous call should not give a next link in this scenario. |
@jianghaolu any update on this issue? |
I meant this in my previous comment: 1st page : [1, 2, 3] |
Why non? The library should be resilient to empty page and iterate as long as the next page exists. |
Why would you return an empty page in the first place? |
That depends on paging implementations on the service side. However, the good design on the client side is to be resilient with these issues instead of assuming that service is always returning the expected value. |
In my opinion, it's just the code on the server side not handling the edge condition well. You may think it's just an extra loop on your server side, on the client-side it's a round-trip REST call that brings no value to the client. |
Fair point. In this case, service would return empty page with next page link. This doesn't mean that the client should fail hard because it didn't expect service to return empty page. The protocol design is that the page includes at most the page maximum, but there is no protocol on the minimum list in this case. Azure Java SDK is the only language that is failing on this. |
Yeah of course. No other language is helping you group all pages together. |
With that being said, I agree it's a nice thing to have on the client-side. We already have an issue discussing paging improvements here: Azure/azure-sdk-for-java#1022. Feel free to jump in. |
This fails on Python too. It throws a 'NoneType is not iterable' TypeError. |
@tjprescott This might affect every language that has a automatic paging feature. That includes Java, Python, and Ruby. @annatisch @vishrutshah @veronicagg |
For Ruby, we see this issue surface in datalake data plane services, we haven't generated these ones yet, we'll take a look into the issue soon. |
Ruby: |
closing as it appears to have been addressed |
When listing all items as below, the for loop
for (CertificateItem item : listResult)
will throw a NoSuchElementException intermittently.The exception that is thrown and the stack trace:
The exception is thrown because there is no other elements left to get the next(). There should be a condition before .next() to check whether there is an element:
Iterator.hasNext()
The text was updated successfully, but these errors were encountered: