realm.write {
// Query for the parent frog object with ponds
val frog = query<Frog>("name == $0", "Kermit").find().first()
val ponds = frog.favoritePonds
// Iterate over the list and delete each pond object
if (ponds.isNotEmpty()) {
ponds.forEach { pond ->
delete(pond)
}
}
// Delete the parent frog object
val frogToDelete = findLatest(frog)
if (frogToDelete != null) {
delete(frogToDelete)
}
}
The exception of
java.util.NoSuchElementException at java.util.AbstractList$Itr.next(AbstractList.java:364)
happens at the line of delete(pond)
To fix it, this line:
val ponds = frog.favoritePonds
needs to be changed to:
val ponds = frog.favoritePonds.toList()
How frequently does the bug occur?
Always
Description
from the documentation:
The exception of
java.util.NoSuchElementException at java.util.AbstractList$Itr.next(AbstractList.java:364)
happens at the line of delete(pond)To fix it, this line:
val ponds = frog.favoritePonds
needs to be changed to:val ponds = frog.favoritePonds.toList()
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
No response
Version
2.00
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Android 9
Build environment
Android Studio version: ... Android Build Tools version: ... Gradle version: ...