{"action":"created","issue":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/3626","repository_url":"https://api.github.com/repos/robolectric/robolectric","labels_url":"https://api.github.com/repos/robolectric/robolectric/issues/3626/labels{/name}","comments_url":"https://api.github.com/repos/robolectric/robolectric/issues/3626/comments","events_url":"https://api.github.com/repos/robolectric/robolectric/issues/3626/events","html_url":"https://github.com/robolectric/robolectric/pull/3626","id":283685936,"number":3626,"title":"Load SharedPreferences from disk synchronously.","user":{"login":"brettchabot","id":4038919,"avatar_url":"https://avatars2.githubusercontent.com/u/4038919?v=4","gravatar_id":"","url":"https://api.github.com/users/brettchabot","html_url":"https://github.com/brettchabot","followers_url":"https://api.github.com/users/brettchabot/followers","following_url":"https://api.github.com/users/brettchabot/following{/other_user}","gists_url":"https://api.github.com/users/brettchabot/gists{/gist_id}","starred_url":"https://api.github.com/users/brettchabot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettchabot/subscriptions","organizations_url":"https://api.github.com/users/brettchabot/orgs","repos_url":"https://api.github.com/users/brettchabot/repos","events_url":"https://api.github.com/users/brettchabot/events{/privacy}","received_events_url":"https://api.github.com/users/brettchabot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-20T20:29:29Z","updated_at":"2017-12-21T01:43:59Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/robolectric/robolectric/pulls/3626","html_url":"https://github.com/robolectric/robolectric/pull/3626","diff_url":"https://github.com/robolectric/robolectric/pull/3626.diff","patch_url":"https://github.com/robolectric/robolectric/pull/3626.patch"},"body":"The Android framework will fork a thread to read SharedPreferences from\r\ndisk on construction.\r\n\r\nThere is a potential race condition, where this thread might still be\r\nactive when test finishes, causing collisions betweem tests.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/comments/353234186","html_url":"https://github.com/robolectric/robolectric/pull/3626#issuecomment-353234186","issue_url":"https://api.github.com/repos/robolectric/robolectric/issues/3626","id":353234186,"user":{"login":"roostertech","id":2434770,"avatar_url":"https://avatars1.githubusercontent.com/u/2434770?v=4","gravatar_id":"","url":"https://api.github.com/users/roostertech","html_url":"https://github.com/roostertech","followers_url":"https://api.github.com/users/roostertech/followers","following_url":"https://api.github.com/users/roostertech/following{/other_user}","gists_url":"https://api.github.com/users/roostertech/gists{/gist_id}","starred_url":"https://api.github.com/users/roostertech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roostertech/subscriptions","organizations_url":"https://api.github.com/users/roostertech/orgs","repos_url":"https://api.github.com/users/roostertech/repos","events_url":"https://api.github.com/users/roostertech/events{/privacy}","received_events_url":"https://api.github.com/users/roostertech/received_events","type":"User","site_admin":false},"created_at":"2017-12-21T01:43:59Z","updated_at":"2017-12-21T01:43:59Z","author_association":"NONE","body":"The tests are passing now. However, I think the problem is just being bypassed?\r\n\r\nThe real startLoadFromDisk  reset mLoaded before entering loadFromDiskLocked. Otherwise when called through startReloadIfChangedUnexpectedly, loadFromDiskLocked -> NOP.\r\n\r\nContextImpl: ~365\r\n\r\n```\r\n        if ((mode & Context.MODE_MULTI_PROCESS) != 0 ||\r\n            getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {\r\n            // If somebody else (some other process) changed the prefs\r\n            // file behind our back, we reload it.  This has been the\r\n            // historical (if undocumented) behavior.\r\n            sp.startReloadIfChangedUnexpectedly();\r\n        }\r\n```\r\n\r\n```\r\n\"main@1\" prio=5 tid=0x1 nid=NA runnable\r\n  java.lang.Thread.State: RUNNABLE\r\n\t  at org.robolectric.shadows.ShadowSharedPreferencesImpl.startLoadFromDisk(ShadowSharedPreferencesImpl.java:24)\r\n\t  at java.lang.invoke.LambdaForm$DMH.253558788.invokeVirtual_L_V(LambdaForm$DMH:-1)\r\n\t  at java.lang.invoke.LambdaForm$BMH.1234329919.reinvoke(LambdaForm$BMH:-1)\r\n\t  at java.lang.invoke.LambdaForm$reinvoker.893640573.dontInline(LambdaForm$reinvoker:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.2085886997.guard(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.893523498.linkToCallSite(LambdaForm$MH:-1)\r\n\t  at android.app.SharedPreferencesImpl.startLoadFromDisk(SharedPreferencesImpl.java:-1)\r\n\t  at android.app.SharedPreferencesImpl.$$robo$$startReloadIfChangedUnexpectedly(SharedPreferencesImpl.java:144)\r\n\t  - locked <0xb89> (a android.app.SharedPreferencesImpl)\r\n\t  at java.lang.invoke.LambdaForm$DMH.172794870.invokeSpecial_L_V(LambdaForm$DMH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.707531688.guardWithCatch(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$reinvoker.893640573.dontInline(LambdaForm$reinvoker:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.2085886997.guard(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.893523498.linkToCallSite(LambdaForm$MH:-1)\r\n\t  at android.app.SharedPreferencesImpl.startReloadIfChangedUnexpectedly(SharedPreferencesImpl.java:-1)\r\n\t  at android.app.ContextImpl.$$robo$$getSharedPreferences(ContextImpl.java:625)\r\n\t  at java.lang.invoke.LambdaForm$DMH.227755469.invokeSpecial_LLI_L(LambdaForm$DMH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.44249014.guardWithCatch(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$reinvoker.300659126.dontInline(LambdaForm$reinvoker:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.179233442.guard(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.254812619.linkToCallSite(LambdaForm$MH:-1)\r\n\t  at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:-1)\r\n\t  at android.content.ContextWrapper.$$robo$$getSharedPreferences(ContextWrapper.java:153)\r\n\t  at java.lang.invoke.LambdaForm$DMH.227755469.invokeSpecial_LLI_L(LambdaForm$DMH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.44249014.guardWithCatch(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$reinvoker.300659126.dontInline(LambdaForm$reinvoker:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.179233442.guard(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.254812619.linkToCallSite(LambdaForm$MH:-1)\r\n\t  at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:-1)\r\n\t  at android.preference.PreferenceManager.$$robo$$getDefaultSharedPreferences(PreferenceManager.java:366)\r\n\t  at java.lang.invoke.LambdaForm$DMH.1053631449.invokeStatic_L_L(LambdaForm$DMH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.2087785333.guardWithCatch(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$reinvoker.1846501247.dontInline(LambdaForm$reinvoker:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.671471369.guard(LambdaForm$MH:-1)\r\n\t  at java.lang.invoke.LambdaForm$MH.1055096410.linkToCallSite(LambdaForm$MH:-1)\r\n\t  at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:-1)\r\n\t  at org.robolectric.shadows.ShadowSharedPreferencesTest.defaultSharedPreferences(ShadowSharedPreferencesTest.java:213)\r\n\t  at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)\r\n\t  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\t  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\t  at java.lang.reflect.Method.invoke(Method.java:498)\r\n\t  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)\r\n\t  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\r\n\t  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)\r\n\t  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\r\n\t  at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:536)\r\n\t  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\r\n\t  at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:249)\r\n\t  at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:123)\r\n\t  at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)\r\n\t  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\r\n\t  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\r\n\t  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\r\n\t  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\r\n\t  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\r\n\t  at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:77)\r\n\t  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)\r\n\t  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)\r\n\t  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)\r\n\t  at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)\r\n\t  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)\r\n\t  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)\r\n```\r\n"}}
{"actor":{"display_login":"roostertech"}}