在我的Android application中,我不时遇到以下 RuntimeException 。我知道黛安·哈克伯恩(Dianne Hackborn)说过the database does not have to be closed。
但是,我对UpdateService
毕竟无法获得readableDatabase
的原因更感兴趣?
Caused by: java.lang.IllegalStateException: Cannot perform this operation
because the connection pool has been closed.
at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:1034)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:731)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:369)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at info.metadude.android.eventfahrplan.database.repositories.MetaDatabaseRepository.query(MetaDatabaseRepository.kt:45)
at nerd.tuxmobil.fahrplan.congress.repositories.AppRepository.readMeta(AppRepository.kt:222)
at nerd.tuxmobil.fahrplan.congress.autoupdate.UpdateService.onHandleWork(UpdateService.java:123)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:391)
at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
与additional logging类似的堆栈跟踪:
Caused by: java.lang.IllegalStateException: Cannot perform this operation
because the connection pool has been closed.
at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:1069)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:683)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:378)
at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:149)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:137)
at info.metadude.android.eventfahrplan.database.repositories.LecturesDatabaseRepository.query(LecturesDatabaseRepository.kt:62)
at info.metadude.android.eventfahrplan.database.repositories.LecturesDatabaseRepository.queryLecturesOrderedByDateUtc(LecturesDatabaseRepository.kt:45)
at nerd.tuxmobil.fahrplan.congress.repositories.AppRepository.readLecturesOrderedByDateUtc(AppRepository.kt:211)
at nerd.tuxmobil.fahrplan.congress.repositories.AppRepository.readDateInfos(AppRepository.kt:214)
at nerd.tuxmobil.fahrplan.congress.utils.FahrplanMisc.loadDays(FahrplanMisc.java:49)
at nerd.tuxmobil.fahrplan.congress.schedule.MainActivity.onCreate(MainActivity.java:107)
at android.app.Activity.performCreate(Activity.java:7144)
... 13 more
日志:
1 D: MainActivity#onParseDone
2 D: AppRepository#storeConferenceDays
3 D: MyApp.meta = Meta(dayChangeHour=4, dayChangeMinute=0, eTag=, numDays=3, subtitle=, title=, version=1.0.0)
4 D: viewDay(false)
5 D: fetch was pending, restart
6 D: MyApp.task_running = FETCH
7 D: lecture_id = null
8 D: MyApp.lectureList contains 57 items.
9 D: onResume
10 D: MainActivity#onParseDone
11 D: UpdateService#onHandleWork
12 D: UpdateService#fetchFahrplan
13 D: UpdateService#onHandleWork
14 D: MyApp.meta = Meta(dayChangeHour=4, dayChangeMinute=0, eTag=, numDays=3, subtitle=, title=, version=1.0.0)
15 D: viewDay(false)
16 D: meta.getNumDays() = 3
17 D: MyApp.task_running = NONE
18 D: lecture_id = null
19 D: MyApp.lectureList contains 57 items.
20 D: onResume
21 D: MainActivity#onParseDone
22 D: MyApp.meta = Meta(dayChangeHour=4, dayChangeMinute=0, eTag=, numDays=3, subtitle=, title=, version=1.0.0)