Merge pull request #3526 from deltachat/adb/issue-3525

use synchronized block to avoid IllegalMonitorStateException
This commit is contained in:
adb 2025-01-10 16:06:13 +01:00 committed by GitHub
commit 9d244611bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View file

@ -49,7 +49,7 @@ jobs:
run: ./gradlew --no-daemon assembleGplayDebug
- name: Upload APK
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: app-preview.apk
path: 'build/outputs/apk/gplay/debug/*.apk'

View file

@ -49,6 +49,7 @@ public final class FetchForegroundService extends Service {
// The background fetch was successful, but we need to wait until all events were processed.
// After all events were processed, we will get DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE,
// and stop() will be called.
synchronized (STOP_NOTIFIER) {
while (fetchingSynchronously) {
try {
// The `wait()` needs to be enclosed in a while loop because there may be
@ -59,12 +60,15 @@ public final class FetchForegroundService extends Service {
}
}
}
}
public static void stop(Context context) {
if (fetchingSynchronously) {
fetchingSynchronously = false;
synchronized (STOP_NOTIFIER) {
STOP_NOTIFIER.notifyAll();
}
}
synchronized (SERVICE_LOCK) {
if (service != null) {