objectbox-java: Sproadic crash with "No entity found with the name" error.
Sporadically my application crashes when trying to create query from ObjectBox object with stacktrace like this:
io.objectbox.exception.DbException: No entity found with the name AlarmEntry
at io.objectbox.query.QueryBuilder.nativeCreate(Native Method)
at io.objectbox.query.QueryBuilder.<init>(QueryBuilder.java:5)
at io.objectbox.Box.query(Box.java:1)
at com.acme.MyService.getByKeyQuery(MyService.kt:3)
AlamrEntry entity obviously do exist. Query works like 99.9% of the time.
Basic info:
- ObjectBox version: 3.5.0
- Reproducibility: occasionally without visible pattern
- Device: Sony XQ-AU52
- OS: Android 11
Expected behavior No crash.
Code
class MyService() {
...
private val alarmEntryBox: Box<AlarmEntry> = box.boxFor(AlarmEntry::class.java)
private val byKeyQuery
get() = alarmEntryBox.query()
.equal(AlarmEntry_.key, "", QueryBuilder.StringOrder.CASE_SENSITIVE)
.parameterAlias("key")
.equal(AlarmEntry_.rootUid, "", QueryBuilder.StringOrder.CASE_SENSITIVE)
.parameterAlias("rootUid")
.equal(AlarmEntry_.source, 0)
.parameterAlias("source")
.orderDesc(AlarmEntry_.changeId)
.build()
...
// methods that use this query
}
Additional context Call happens in a coroutine and multiple threads can make it simultaneously.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 27 (11 by maintainers)
😃 I’ll watch if this keep appearing and maybe will find some logic behind it
Yes, I’m aware that query is not thread safe and this is exactly why there is on-demand getter for query. I’ll double check my code if maybe query is re-used in different threads anyway.
This is my test device or rather this is one of very few models we use in production. We don’t have a lot of users for now and it is hard to tell if this affect other devices/models/os versions because we don’t have these yet.
3.5.1. not released yet as far as I can tell… isn’t it?