Azure / Azure/azure-iot-service-sdk-java

JobQueryResponse next() throws NoSuchElementException even though hasNext() return true

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5
Forks
14
PR merge metrics
No merged PRs in 30d

Description

Got job query as follows:
'select * from devices.jobs'

The ScheduledJobsClient returns JobQueryResponse. And we use below loop mechanism to get jobs from the query.
while (response.hasNext()) {
job = response.next() // =======> throws exception NoSuchElementException at the end.
}

Exception in "" java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(Unknown Source)
at com.microsoft.azure.sdk.iot.service.query.JobQueryResponse.next(JobQueryResponse.java:148)
at com.microsoft.azure.sdk.iot.service.query.JobQueryResponse.next(JobQueryResponse.java:99)

As a work around we are using below handler to handle to case.
while (response.hasNext()) {
try {
job = response.next()
} catch (ex: NoSuchElementException) {
// exit loop
}
}

Looks like hasNext() and next() do not work as intended.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.