Skip to content

Commit

Permalink
Merge pull request #13345 from nextcloud/npe-check-dispatchResultToOp…
Browse files Browse the repository at this point in the history
…erationListeners

Check Nullability of mOperationsBinder
  • Loading branch information
AndyScherzinger authored Jul 31, 2024
2 parents 37e83c3 + d68f0a9 commit 38cbae1
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -775,23 +775,24 @@ private User toUser(@Nullable Account account) {
* @param operation Finished operation.
* @param result Result of the operation.
*/
protected void dispatchResultToOperationListeners(
final RemoteOperation operation, final RemoteOperationResult result
) {
protected void dispatchResultToOperationListeners(final RemoteOperation operation, final RemoteOperationResult result) {
int count = 0;
Iterator<OnRemoteOperationListener> listeners = mOperationsBinder.mBoundListeners.keySet().iterator();
while (listeners.hasNext()) {
final OnRemoteOperationListener listener = listeners.next();
final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
if (handler != null) {
handler.post(() -> listener.onRemoteOperationFinish(operation, result));
count += 1;

if (mOperationsBinder != null) {
for (OnRemoteOperationListener listener : mOperationsBinder.mBoundListeners.keySet()) {
final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
if (handler != null) {
handler.post(() -> listener.onRemoteOperationFinish(operation, result));
count += 1;
}
}
}

if (count == 0) {
Pair<RemoteOperation, RemoteOperationResult> undispatched = new Pair<>(operation, result);
mUndispatchedFinishedOperations.put(operation.hashCode(), undispatched);
}

Log_OC.d(TAG, "Called " + count + " listeners");
}
}

0 comments on commit 38cbae1

Please sign in to comment.