Skip to content

Commit b874ef5

Browse files
CR: comments
1 parent fe4e0ce commit b874ef5

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

server/src/main/java/org/elasticsearch/repositories/GetSnapshotInfoContext.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public final class GetSnapshotInfoContext implements ActionListener<SnapshotInfo
4444

4545
/**
4646
* Listener resolved when fetching {@link SnapshotInfo} has completed. If resolved successfully, no more calls to
47-
* {@link #onSnapshotInfo} will be made. Only resolves exceptionally if {@link #abortOnFailure} is true in case one or more
47+
* {@link #consumer} will be made. Only resolves exceptionally if {@link #abortOnFailure} is true in case one or more
4848
* {@link SnapshotInfo} failed to be fetched.
4949
*/
5050
private final ActionListener<Void> doneListener;
@@ -53,23 +53,25 @@ public final class GetSnapshotInfoContext implements ActionListener<SnapshotInfo
5353
* {@link BiConsumer} invoked for each {@link SnapshotInfo} that is fetched with this instance and the {@code SnapshotInfo} as
5454
* arguments.
5555
*/
56-
private final BiConsumer<GetSnapshotInfoContext, SnapshotInfo> onSnapshotInfo;
56+
private final BiConsumer<GetSnapshotInfoContext, SnapshotInfo> consumer;
5757

5858
private final CountDown counter;
5959

6060
public GetSnapshotInfoContext(
6161
Collection<SnapshotId> snapshotIds,
6262
boolean abortOnFailure,
6363
BooleanSupplier isCancelled,
64-
BiConsumer<GetSnapshotInfoContext, SnapshotInfo> onSnapshotInfo,
64+
BiConsumer<GetSnapshotInfoContext, SnapshotInfo> consumer,
6565
ActionListener<Void> listener
6666
) {
67-
assert snapshotIds.isEmpty() == false : "no snapshot ids to fetch given";
67+
if (snapshotIds.isEmpty()) {
68+
throw new IllegalArgumentException("no snapshot ids to fetch given");
69+
}
6870
this.snapshotIds = List.copyOf(snapshotIds);
6971
this.counter = new CountDown(snapshotIds.size());
7072
this.abortOnFailure = abortOnFailure;
7173
this.isCancelled = isCancelled;
72-
this.onSnapshotInfo = onSnapshotInfo;
74+
this.consumer = consumer;
7375
this.doneListener = listener;
7476
}
7577

@@ -101,7 +103,7 @@ public boolean done() {
101103
@Override
102104
public void onResponse(SnapshotInfo snapshotInfo) {
103105
try {
104-
onSnapshotInfo.accept(this, snapshotInfo);
106+
consumer.accept(this, snapshotInfo);
105107
} catch (Exception e) {
106108
assert false : e;
107109
onFailure(e);

server/src/test/java/org/elasticsearch/repositories/RepositoriesServiceTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ public RepositoryMetadata getMetadata() {
202202
}
203203

204204
@Override
205-
public void getSnapshotInfo(GetSnapshotInfoContext context) {}
205+
public void getSnapshotInfo(GetSnapshotInfoContext context) {
206+
throw new UnsupportedOperationException();
207+
}
206208

207209
@Override
208210
public Metadata getSnapshotGlobalMetadata(SnapshotId snapshotId) {

test/framework/src/main/java/org/elasticsearch/index/shard/RestoreOnlyRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public RepositoryMetadata getMetadata() {
6565

6666
@Override
6767
public void getSnapshotInfo(GetSnapshotInfoContext context) {
68+
throw new UnsupportedOperationException();
6869
}
6970

7071
@Override

0 commit comments

Comments
 (0)