Skip to content

Commit

Permalink
Merge pull request #3526 from deltachat/adb/issue-3525
Browse files Browse the repository at this point in the history
use synchronized block to avoid IllegalMonitorStateException
  • Loading branch information
adbenitez authored Jan 10, 2025
2 parents 05da434 + 3533916 commit 9d24461
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preview-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ public static void start(Context context) {
// 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.
while (fetchingSynchronously) {
try {
// The `wait()` needs to be enclosed in a while loop because there may be
// "spurious wake-ups", i.e. `wait()` may return even though `notifyAll()` wasn't called.
STOP_NOTIFIER.wait();
} catch (InterruptedException ex) { }
synchronized (STOP_NOTIFIER) {
while (fetchingSynchronously) {
try {
// The `wait()` needs to be enclosed in a while loop because there may be
// "spurious wake-ups", i.e. `wait()` may return even though `notifyAll()` wasn't called.
STOP_NOTIFIER.wait();
} catch (InterruptedException ex) {}
}
}
}
}
Expand All @@ -63,7 +65,9 @@ public static void start(Context context) {
public static void stop(Context context) {
if (fetchingSynchronously) {
fetchingSynchronously = false;
STOP_NOTIFIER.notifyAll();
synchronized (STOP_NOTIFIER) {
STOP_NOTIFIER.notifyAll();
}
}

synchronized (SERVICE_LOCK) {
Expand Down

0 comments on commit 9d24461

Please sign in to comment.