Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ private interface Callback {

public static final String TAG = "FirebaseCb";

// Object used to synchronize around. All synchronization should be done with this,
// as there isn't a guarantee on which function will be called first.
private final Object lockObject = new Object();

/**
* This class is registered with a Task object as an OnSuccessListener, OnFailureListener, and
* OnCanceledListener, redirecting completion status to the C++ method nativeOnResult.
*/
private class TaskCallback<TResult>
implements OnSuccessListener<TResult>, OnFailureListener, OnCanceledListener, Callback {
private Task<TResult> task;
private final Object lockObject = new Object();
/**
* Register with a Task instance to capture the completion callback.
*/
Expand Down Expand Up @@ -129,7 +132,7 @@ protected void initializeNativeCallbackFunctionAndData(long callbackFn, long cal

/** Initialize / attach the instance to a pending result or task object. */
protected void initializeWithTask(Task<TResult> task) {
synchronized (this) {
synchronized (lockObject) {
callbackHandler = new TaskCallback<TResult>(task);
callbackHandler.register();
}
Expand All @@ -146,7 +149,7 @@ public void cancel() {
/** Call nativeOnResult with the registered callbackFn and callbackData. */
public void onCompletion(
Object result, boolean success, boolean cancelled, String statusMessage) {
synchronized (this) {
synchronized (lockObject) {
if (callbackHandler != null) {
nativeOnResult(result, success, cancelled, statusMessage, callbackFn, callbackData);
callbackHandler.disconnect();
Expand Down
2 changes: 2 additions & 0 deletions release_build_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ code.
## Release Notes
### Upcoming Release
- Changes
- General (Android): Fix for deadlock within JniResultCallback, commonly
seen within Messaging, but affecting other products as well.
- Database/Firestore (Desktop): Fixed a crash on Windows when the user's
home directory contains non-ANSI characters (Unicode above U+00FF).
- Storage (Desktop): Fixed a crash on Windows when uploading files from a
Expand Down