Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use synchronized block to avoid IllegalMonitorStateException #3526

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

adbenitez
Copy link
Member

close #3525

@adbenitez adbenitez added the bug label Jan 9, 2025
@adbenitez adbenitez requested review from r10s and Hocuri January 9, 2025 17:38
@adbenitez adbenitez self-assigned this Jan 9, 2025
@adbenitez
Copy link
Member Author

oh mannnn, all the CI actions decided to go nuts right on my PR

@r10s
Copy link
Member

r10s commented Jan 9, 2025

what exactly does synchronized do? if it is sort of mutula-exclusive-critical-section, and wait would get access to that, notifyAll could never be called. but not sure, i am currently deep in iOS release thingies ...

Copy link

github-actions bot commented Jan 9, 2025

To test the changes in this pull request, install this apk:
📦 app-preview.apk

@adbenitez
Copy link
Member Author

what exactly does synchronized do? if it is sort of mutula-exclusive-critical-section, and wait would get access to that, notifyAll could never be called. but not sure, i am currently deep in iOS release thingies ...

I was wondering exactly the same, that is why I was a bit skeptical when read that it is the solution to the problem in https://stackoverflow.com/a/24186147

but then I searched our code and in all other places where we use wait() and notifyAll() we always do it exactly as recommended inside a synchronized block, so then I assume it is fine without further investigation, plus the crash by android is telling that you must lock the object before making the call in both cases

Comment on lines 53 to 61
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();
synchronized (STOP_NOTIFIER) {
STOP_NOTIFIER.wait();
}
} catch (InterruptedException ex) { }
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation, you're supposed to put the synchronized around the while?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I can't create a suggestion here on GitHub (since it would touch unchanged lines), I just pushed a commit with my suggestion

Copy link
Collaborator

@Hocuri Hocuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's amazing how hard these Java APIs are to be used correctly XD

Thanks for caring!

uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commited accidentally?

Copy link
Member Author

@adbenitez adbenitez Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI fails otherwise (v3 is deprecated)

@adbenitez adbenitez merged commit 9d24461 into main Jan 10, 2025
1 of 2 checks passed
@adbenitez adbenitez deleted the adb/issue-3525 branch January 10, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception due to new push notification handling
3 participants