From 97c7ea60b938467ee2b13970d1ab6895229d5bf4 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Fri, 22 Nov 2019 17:27:27 +0100 Subject: [PATCH] Add Missing Nullable Assertions in SnapshotsService (#49465) (#49492) Just realized we were missing some annotations here which was somewhat confusing since other methods/parameters have the `Nullable` annotation wherever a `null` can be passed. --- .../org/elasticsearch/snapshots/SnapshotsService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index fdda7b6c838..269f7d61659 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -1075,20 +1075,21 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus * Removes record of running snapshot from cluster state * @param snapshot snapshot * @param snapshotInfo snapshot info if snapshot was successful - * @param e exception if snapshot failed + * @param e exception if snapshot failed, {@code null} otherwise */ - private void removeSnapshotFromClusterState(final Snapshot snapshot, final SnapshotInfo snapshotInfo, final Exception e) { + private void removeSnapshotFromClusterState(final Snapshot snapshot, final SnapshotInfo snapshotInfo, @Nullable Exception e) { removeSnapshotFromClusterState(snapshot, snapshotInfo, e, null); } /** * Removes record of running snapshot from cluster state and notifies the listener when this action is complete * @param snapshot snapshot - * @param failure exception if snapshot failed + * @param failure exception if snapshot failed, {@code null} otherwise * @param listener listener to notify when snapshot information is removed from the cluster state */ - private void removeSnapshotFromClusterState(final Snapshot snapshot, @Nullable SnapshotInfo snapshotInfo, final Exception failure, + private void removeSnapshotFromClusterState(final Snapshot snapshot, @Nullable SnapshotInfo snapshotInfo, @Nullable Exception failure, @Nullable CleanupAfterErrorListener listener) { + assert snapshotInfo != null || failure != null : "Either snapshotInfo or failure must be supplied"; clusterService.submitStateUpdateTask("remove snapshot metadata", new ClusterStateUpdateTask() { @Override