objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.35k stars 300 forks source link

LiveData query subscription swallows query exceptions #504

Open tvvbbb opened 5 years ago

tvvbbb commented 5 years ago

When I use arch(LiveData), I found no exception trigged with no empty constructor. But build a query and invoke find() will trigger the exception.

greenrobot commented 5 years ago

@tvvbbb Could you please post the exception stack trace? Thank you!

tvvbbb commented 5 years ago

If I use LiveData, it is no exception. So I can't realize no empty constructor is wrong. But if I only use query().find(), it will make the exception.

greenrobot-team commented 5 years ago

If I understand this correctly, the issue is that a DataSubscription used by ObjectBoxLiveData might swallow exceptions that occured while running a query.

~There is a note in SubscriptionBuilder.ActionObserver.callOnError() (link might stop working with new releases, as I can not link to a tagged version) about this. It was added with 882a2043c13b52f67d424f98bca8930c14436a5d.~

~There is SubscriptionBuilder.onError() to explicitly set an error observer. Maybe we can implement it and throw the exception there?~ -ut

greenrobot-team commented 5 years ago

Could confirm this using the arch example project (added a ToOne relation to Note, made fields private).

Upon further investigation it turns out QueryPublisher.publishSingle() swallows any exceptions from query.find(). -ut

tvvbbb commented 5 years ago

I am so sorry for my poor English. I am not sure to get what you mean actually. https://github.com/tvvbbb/ObjectBoxLiveDataSwallowsException. Comment in MainActivity.

tvvbbb commented 5 years ago

I am sorry for my wrong operation, repository commit failed. Now is successful.

greenrobot-team commented 5 years ago

@tvvbbb OK, so I understood correctly (for me: see my previous comment). Thanks! -ut

tvvbbb commented 5 years ago

Is it a bug?