GoogleCloudPlatform / ide-login

The plugins-login-common library for authenticating with the Google Cloud Platform shared by several IDE plugins including Google Cloud Tools for Eclipse, Google Cloud Tools for IntelliJ, and Android Studio.
Apache License 2.0
2 stars 9 forks source link

Catch & report exceptions during persistence #51

Closed briandealwis closed 5 years ago

briandealwis commented 6 years ago

A user of CT4E encountered a strange issue where the login appeared to succeed, but had no effect. Persisting the result failed, throwing an exception, that was caught and logged but otherwise cause the login to fail.

Exceptions should be caught and reported via the UiFacade#showErrorDialog().

elharo commented 6 years ago

Specifically the error was a SecurityException:

Caused by: java.lang.SecurityException: Could not lock User prefs. Lock file access denied.
    at java.util.prefs.FileSystemPreferences.checkLockFile0ErrorCode(FileSystemPreferences.java:937)
    at java.util.prefs.FileSystemPreferences.lockFile(FileSystemPreferences.java:925)
    at java.util.prefs.FileSystemPreferences.sync(FileSystemPreferences.java:729)
    at java.util.prefs.FileSystemPreferences.flush(FileSystemPreferences.java:824)
    at com.google.cloud.tools.login.JavaPreferenceOAuthDataStore.saveOAuthData(JavaPreferenceOAuthDataStore.java:90)
    at com.google.cloud.tools.login.GoogleLoginState.persistCredentials(GoogleLoginState.java:387)
    at com.google.cloud.tools.login.GoogleLoginState.logInHelper(GoogleLoginState.java:222)
    at com.google.cloud.tools.login.GoogleLoginState.logInWithLocalServer(GoogleLoginState.java:215)
    at com.google.cloud.tools.eclipse.login.GoogleLoginService.logIn(GoogleLoginService.java:120)
    at com.google.cloud.tools.eclipse.login.ui.GoogleLoginCommandHandler.execute(GoogleLoginCommandHandler.java:37)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:291)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
    ... 37 more
elharo commented 6 years ago

saveOAuthData and loadOAuthData should both throw checked IOExceptions instead of merely logging since these operations do occasionally fail and clients need to handle that case.

elharo commented 5 years ago

fixed by #52