{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/3720","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/3720/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/3720/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/3720/events","html_url":"https://github.com/realm/realm-java/issues/3720","id":186066836,"number":3720,"title":"Trying to delete Realm but somehow an instance of realm is open","user":{"login":"mihirjoshi21","id":5195121,"avatar_url":"https://avatars.githubusercontent.com/u/5195121?v=3","gravatar_id":"","url":"https://api.github.com/users/mihirjoshi21","html_url":"https://github.com/mihirjoshi21","followers_url":"https://api.github.com/users/mihirjoshi21/followers","following_url":"https://api.github.com/users/mihirjoshi21/following{/other_user}","gists_url":"https://api.github.com/users/mihirjoshi21/gists{/gist_id}","starred_url":"https://api.github.com/users/mihirjoshi21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mihirjoshi21/subscriptions","organizations_url":"https://api.github.com/users/mihirjoshi21/orgs","repos_url":"https://api.github.com/users/mihirjoshi21/repos","events_url":"https://api.github.com/users/mihirjoshi21/events{/privacy}","received_events_url":"https://api.github.com/users/mihirjoshi21/received_events","type":"User","site_admin":false},"labels":[{"id":3545600,"url":"https://api.github.com/repos/realm/realm-java/labels/T:Help","name":"T:Help","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-29T08:25:01Z","updated_at":"2016-11-05T09:26:45Z","closed_at":null,"body":"It is only happening in like 1 percent of the production devices.\n\nI have an old pre-shipped realm file which I want to replace with the new version of the realm file after copying user data from the old file.\n\n```\nRealm realm = null;\ntry {\n realm = Realm.getDefaultInstance();\n\n RealmQuery < WordHistoryModel > query = realm.where(WordHistoryModel.class);\n RealmResults < WordHistoryModel > result = query.findAllSorted(\"timeLong\", Sort.DESCENDING);\n if (!result.isEmpty()) {\n  mHistory = ProjectUtil.getGsonInstance().toJson(result);\n }\n} catch (Exception realmError) {\n realmError.printStackTrace();\n Crashlytics.logException(realmError);\n}\nif (realm != null && !realm.isClosed()) {\n realm.close();\n}\n}\n\nRealm.deleteRealm(ProjectUtil.getRealmConfiguration(ProjectUtil.getSharedPreferencesInt(mActivity,\n AppConstants.DATABASE_VERSION)));\nRealm.removeDefaultConfiguration();\n```\n\nThis is on the splash screen and the first time when I am opening the realm instance but when I am deleting the realm file there is an illegalStateException that the realm file is still open.\nIs there a way to release all instances from realm cache?\n"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/258600572","html_url":"https://github.com/realm/realm-java/issues/3720#issuecomment-258600572","issue_url":"https://api.github.com/repos/realm/realm-java/issues/3720","id":258600572,"user":{"login":"mihirjoshi21","id":5195121,"avatar_url":"https://avatars.githubusercontent.com/u/5195121?v=3","gravatar_id":"","url":"https://api.github.com/users/mihirjoshi21","html_url":"https://github.com/mihirjoshi21","followers_url":"https://api.github.com/users/mihirjoshi21/followers","following_url":"https://api.github.com/users/mihirjoshi21/following{/other_user}","gists_url":"https://api.github.com/users/mihirjoshi21/gists{/gist_id}","starred_url":"https://api.github.com/users/mihirjoshi21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mihirjoshi21/subscriptions","organizations_url":"https://api.github.com/users/mihirjoshi21/orgs","repos_url":"https://api.github.com/users/mihirjoshi21/repos","events_url":"https://api.github.com/users/mihirjoshi21/events{/privacy}","received_events_url":"https://api.github.com/users/mihirjoshi21/received_events","type":"User","site_admin":false},"created_at":"2016-11-05T09:26:45Z","updated_at":"2016-11-05T09:26:45Z","body":"So I updated my app closing a realm instance opened by the Service. From past two days, there is no bug. I am waiting for few more days to see if it's resolved or not."}}
{"actor":{"display_login":"mihirjoshi21"}}