Updater swallowing important exceptions
In order to prevent network errors causing crashes when updating repositories, the repo updater catches exceptions (and shows them in a Toast
). I suspect that it catches very general exceptions (i.e. Exception
) because there are many different types of network problems which could be of interest. However, it is currently also swallowing SQLiteConstraintException
s such as the following:
SQLiteLog E (1555) abort at 56 in [INSERT INTO fdroid_apk SELECT * FROM temp_update_db.temp_fdroid_apk]: UNIQUE constr
aint failed: fdroid_apk.appId, fdroid_apk.vercode, fdroid_apk.repo
UpdateService E Exception during update processing
E android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: fdroid_apk.appId, fdroid_apk.
vercode, fdroid_apk.repo (code 1555)
E at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
E at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:736)
E at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
E at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
E at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1676)
E at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)
E at org.fdroid.fdroid.data.TempAppProvider.commitTable(TempAppProvider.java:182)
E at org.fdroid.fdroid.data.TempAppProvider.insert(TempAppProvider.java:116)
E at android.content.ContentProvider$Transport.insert(ContentProvider.java:239)
E at android.content.ContentResolver.insert(ContentResolver.java:1207)
E at org.fdroid.fdroid.data.TempAppProvider$Helper.commitAppsAndApks(TempAppProvider.java:99)
E at org.fdroid.fdroid.data.RepoPersister.commit(RepoPersister.java:70)
E at org.fdroid.fdroid.RepoUpdater.commitToDb(RepoUpdater.java:237)
E at org.fdroid.fdroid.RepoUpdater.processDownloadedFile(RepoUpdater.java:213)
E at org.fdroid.fdroid.RepoUpdater.update(RepoUpdater.java:150)
E at org.fdroid.fdroid.UpdateService.onHandleIntent(UpdateService.java:355)
E at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E at android.os.Handler.dispatchMessage(Handler.java:102)
E at android.os.Looper.loop(Looper.java:135)
E at android.os.HandlerThread.run(HandlerThread.java:61)
In this particular case, I investigated and it seems to be that my database got itself into a sad state, quite likely while I was toying with development of the database. I don't think it is a bug in production.
However, problems such as this that do make it into production should be logged to ACRA at least. I suspect this could be done by instead catching only IOException
.
Thoughts @mvdan, @eighthave , others?