java.lang.IllegalStateException: Illegal State: Row/Object is no longer valid to operate on. Was it deleted?
See original GitHub issueHello,
I`m getting java.lang.IllegalStateException: Illegal State: Row/Object is no longer valid to operate on. Was it deleted?
Info From Crashlytics Samsung-SM-G850A Android 5.0.2
HTC ONE X+ Android 4.2.2
I`m using buzzboxSDK-0.6.5.jar
Raw error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cashdivider.app/com.cashdivider.app.gui.SettingsActivity}: java.lang.IllegalStateException: Illegal State: Row/Object is no longer valid to operate on. Was it deleted? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2790) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2855) at android.app.ActivityThread.access$900(ActivityThread.java:181) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1474) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6117) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) Caused by: java.lang.IllegalStateException: Illegal State: Row/Object is no longer valid to operate on. Was it deleted? at io.realm.internal.Row.nativeIsNullLink(Row.java) at io.realm.internal.Row.isNullLink(Row.java:156) at io.realm.BackendRealmProxy.getCurrency(BackendRealmProxy.java:81) at com.cashdivider.app.gui.fragment.SettingsFragment.init(SettingsFragment.java:249) at com.cashdivider.app.gui.fragment.SettingsFragment.onCreate(SettingsFragment.java:74) at android.support.v4.app.Fragment.performCreate(Fragment.java:1766) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:917) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1120) at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:1924) at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:268) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:58) at com.cashdivider.app.gui.BaseActivity.onCreate(BaseActivity.java:90) at com.cashdivider.app.gui.SettingsActivity.onCreate(SettingsActivity.java:22) at android.app.Activity.performCreate(Activity.java:6374) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2743) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2855) at android.app.ActivityThread.access$900(ActivityThread.java:181) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1474) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6117) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (3 by maintainers)
It happens once in a while. No threads involved. Tough to reproduce as it does not happen in second trial.
java.lang.IllegalStateException: Illegal State: Object is no longer valid to operate on. Was it deleted by another thread? at io.realm.internal.UncheckedRow.nativeGetLong(UncheckedRow.java) at io.realm.internal.UncheckedRow.getLong(UncheckedRow.java:129) at io.realm.EstimateRealmProxy.realmGet$id(EstimateRealmProxy.java:107) at co.desque.app.workm.model.Estimate.getId(Estimate.java:36) at co.desque.app.workm.estimates.EstimationDetailFragment.makeInvoice(EstimationDetailFragment.java:423) at co.desque.app.workm.estimates.EstimationDetailFragment.onOptionsItemSelected(EstimationDetailFragment.java:196)
Hi @rilley The most likely reason is as the exception says. That you are holding on to a reference that some other threads deleted. Note that Realm is zero-copy. This means that if you query for the same object on two different threads you are actually holding a reference to the same data. Each RealmObject has a
.isValid()
method you can use if you want to verify that an object is still usable before accessing it.If this is not the case. Can you provide some sample code that provoke this error?