Bugfix Fix NPE FileDataStorageManager#13074
Conversation
|
Hm. DI uses CurrentAccountProvider. So I guess it is okay to use them. But the real fix would be to find out why it is null in first place. Can you see a bit more of stracktrace to guess when this might happen? |
This function set the storage manager inside SessionMixin passed parameter can be null so currentAccount become a null. So can we say both are the same? |
3365117 to
f9ef6da
Compare
8bf8de1 to
18194f8
Compare
|
/rebase |
ZetaTom
left a comment
There was a problem hiding this comment.
On my test device the app crashes on the first launch after a fresh install.
Logcat
FATAL EXCEPTION: main
Process: com.nextcloud.client, PID: 4224
java.lang.RuntimeException: Unable to create application com.owncloud.android.MainApp: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6717)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.nextcloud.client.account.UserAccountManagerImpl.getCurrentAccount(UserAccountManagerImpl.java:157)
at com.nextcloud.client.account.UserAccountManagerImpl.getUser(UserAccountManagerImpl.java:225)
at com.owncloud.android.utils.theme.MaterialSchemesProviderImpl.getMaterialSchemesForCurrentUser(MaterialSchemesProviderImpl.kt:48)
at com.nextcloud.client.di.ThemeModule$Companion.provideMaterialSchemes(ThemeModule.kt:42)
at com.nextcloud.client.di.ThemeModule_Companion_ProvideMaterialSchemesFactory.provideMaterialSchemes(ThemeModule_Companion_ProvideMaterialSchemesFactory.java:47)
at com.nextcloud.client.di.ThemeModule_Companion_ProvideMaterialSchemesFactory.get(ThemeModule_Companion_ProvideMaterialSchemesFactory.java:37)
at com.nextcloud.client.di.ThemeModule_Companion_ProvideMaterialSchemesFactory.get(ThemeModule_Companion_ProvideMaterialSchemesFactory.java:13)
at com.owncloud.android.utils.theme.ViewThemeUtils_Factory.get(ViewThemeUtils_Factory.java:39)
at com.owncloud.android.utils.theme.ViewThemeUtils_Factory.get(ViewThemeUtils_Factory.java:12)
at com.owncloud.android.MainApp.onCreate(MainApp.java:301)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
AnonymousAccount logic added for fresh install. |
@alperozturk96 this seems to be related to your changes. |
|
Have you tested multiple accounts? |
Yes. App is working as expected during my tests. I will fix test and update PR. |
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
032bd46 to
fb9e2e0
Compare
This test is not valid anymore. Account can't be null so I removed the test. |
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/13074.apk |
|
/backport to stable-3.29 |
- UserAccountManagerImpl#getAccountByName() is never null because since nextcloud#13074 it rather returns an anonymous account. To detect an account lookup failure, the type needs to be compared - The getMaterialSchemesProvider() object returned null for most functions, even though they were annotated with @nonnull. Extracted the only actually used function getMaterialSchemesForCurrentUser() Signed-off-by: Philipp Hasper <vcs@hasper.info>
- UserAccountManagerImpl#getAccountByName() is never null because since nextcloud#13074 it rather returns an anonymous account. To detect an account lookup failure, the type needs to be compared - The getMaterialSchemesProvider() object returned null for most functions, even though they were annotated with @nonnull. Extracted the only actually used function getMaterialSchemesForCurrentUser() Signed-off-by: Philipp Hasper <vcs@hasper.info>
- UserAccountManagerImpl#getAccountByName() is never null because since nextcloud#13074 it rather returns an anonymous account. To detect an account lookup failure, the type needs to be compared - The getMaterialSchemesProvider() object returned null for most functions, even though they were annotated with @nonnull. Extracted the only actually used function getMaterialSchemesForCurrentUser() Signed-off-by: Philipp Hasper <vcs@hasper.info>
- UserAccountManagerImpl#getAccountByName() is never null because since #13074 it rather returns an anonymous account. To detect an account lookup failure, the type needs to be compared - The getMaterialSchemesProvider() object returned null for most functions, even though they were annotated with @nonnull. Extracted the only actually used function getMaterialSchemesForCurrentUser() Signed-off-by: Philipp Hasper <vcs@hasper.info>
- UserAccountManagerImpl#getAccountByName() is never null because since #13074 it rather returns an anonymous account. To detect an account lookup failure, the type needs to be compared - The getMaterialSchemesProvider() object returned null for most functions, even though they were annotated with @nonnull. Extracted the only actually used function getMaterialSchemesForCurrentUser() Signed-off-by: Philipp Hasper <vcs@hasper.info>
- UserAccountManagerImpl#getAccountByName() is never null because since nextcloud#13074 it rather returns an anonymous account. To detect an account lookup failure, the type needs to be compared - The getMaterialSchemesProvider() object returned null for most functions, even though they were annotated with @nonnull. Extracted the only actually used function getMaterialSchemesForCurrentUser() Signed-off-by: Philipp Hasper <vcs@hasper.info> Signed-off-by: Raphael Vieira <raphaelecv@hotmail.com>

What this PR Does?
How to Test?