diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index ca834f369777d..b23e0b034d703 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -559,7 +559,7 @@ private Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, St List dataStreams, List featureStates, long startTime, long repositoryStateId, ImmutableOpenMap shards, String failure, Map userMetadata, Version version, @Nullable SnapshotId source, - ImmutableOpenMap shardStatusByRepoShardId) { + @Nullable ImmutableOpenMap shardStatusByRepoShardId) { this.state = state; this.snapshot = snapshot; this.includeGlobalState = includeGlobalState; @@ -659,7 +659,7 @@ private static Entry readFrom(StreamInput in) throws IOException { } return new SnapshotsInProgress.Entry( snapshot, includeGlobalState, partial, state, indices, dataStreams, featureStates, startTime, repositoryStateId, - shards, failure, userMetadata, version, source, source == null ? null : clones); + shards, failure, userMetadata, version, source, clones); } private static boolean assertShardsConsistent(SnapshotId source, State state, Map indices, @@ -1043,8 +1043,11 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringCollection(dataStreams); } if (out.getVersion().onOrAfter(SnapshotsService.CLONE_SNAPSHOT_VERSION)) { - out.writeOptionalWriteable(source); - out.writeMap(shardStatusByRepoShardId); + if (source == null) { + out.writeMap(ImmutableOpenMap.of()); + } else { + out.writeMap(shardStatusByRepoShardId); + } } if (out.getVersion().onOrAfter(FEATURE_STATES_VERSION)) { out.writeList(featureStates);