Merge pull request #13345 from nextcloud/npe-check-dispatchResultToOperationListeners

Check Nullability of mOperationsBinder
This commit is contained in:
Andy Scherzinger 2024-07-31 19:11:36 +02:00 committed by GitHub
commit 38cbae1724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -775,23 +775,24 @@ public class OperationsService extends Service {
* @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");
}
}