-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Distributed Coordination/Snapshot/RestoreAnything directly related to the `_snapshot/*` APIsAnything directly related to the `_snapshot/*` APIsTeam:Distributed (Obsolete)Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination.Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination.
Description
From the following code:
Lines 156 to 166 in f879e84
| public List<SnapshotInfo> getSnapshots(String repo) { | |
| List<SnapshotInfo> snapshots = successfulResponses.get(repo); | |
| if (snapshots != null) { | |
| return snapshots; | |
| } | |
| ElasticsearchException error = failedResponses.get(repo); | |
| if (error == null) { | |
| throw new IllegalArgumentException("No such repository"); | |
| } | |
| throw error; | |
| } |
It's possible for snapshot exceptions to be generated on a different line than where they are actually thrown, for example, code that prior to #42090 worked like this:
GetSnapshotsRequest getSnapshotsRequest = new GetSnapshotsRequest(new String[]{repo}, new String[]{snapshotName});
final GetSnapshotsResponse snaps;
try {
snaps = client.snapshot().get(getSnapshotsRequest, RequestOptions.DEFAULT);
} catch (Exception e) {
if (e.getMessage().contains("snapshot_missing_exception")) {
fail("snapshot does not exist: " + snapshotName);
}
throw e;
}
Optional<SnapshotInfo> info = snaps.getSnapshots(repo).stream().findFirst();
if (info.isPresent()) {
info.ifPresent(si -> {
assertThat(si.snapshotId().getName(), equalTo(snapshotName));
assertThat(si.state(), equalTo(SnapshotState.SUCCESS));
});
} else {
fail("unable to find snapshot; " + snapshotName);
}Now fails.
The exception is generated from the snaps.getSnapshots(repo) call above, however, the stacktrace for the exception actually traces back to the line
snaps = client.snapshot().get(getSnapshotsRequest, RequestOptions.DEFAULT);which is very confusing, because that line itself is wrapped in a try/catch.
GetSnapshotsResponse should change this line:
Line 165 in f879e84
| throw error; |
Into something like
throw new ElasticsearchException(error);So that the stacktrace correctly identifies the caller.
Metadata
Metadata
Assignees
Labels
:Distributed Coordination/Snapshot/RestoreAnything directly related to the `_snapshot/*` APIsAnything directly related to the `_snapshot/*` APIsTeam:Distributed (Obsolete)Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination.Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination.