Skip to content

Commit a4ade1d

Browse files
authored
Wrap immediate refresh callback (#97333)
Relates #95947.
1 parent edc79ff commit a4ade1d

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,15 @@ public void onFailure(Exception e) {
6262
listener.onFailure(e);
6363
}
6464
});
65-
case IMMEDIATE -> immediate(indexShard, new ActionListener<>() {
66-
@Override
67-
public void onResponse(Engine.RefreshResult refreshResult) {
68-
// Fast refresh indices do not depend on the unpromotables being refreshed
69-
boolean fastRefresh = IndexSettings.INDEX_FAST_REFRESH_SETTING.get(indexShard.indexSettings().getSettings());
70-
if (indexShard.getReplicationGroup().getRoutingTable().unpromotableShards().size() > 0 && fastRefresh == false) {
71-
sendUnpromotableRequests(indexShard, refreshResult.generation(), true, listener, postWriteRefreshTimeout);
72-
} else {
73-
listener.onResponse(true);
74-
}
65+
case IMMEDIATE -> immediate(indexShard, listener.delegateFailureAndWrap((l, r) -> {
66+
// Fast refresh indices do not depend on the unpromotables being refreshed
67+
boolean fastRefresh = IndexSettings.INDEX_FAST_REFRESH_SETTING.get(indexShard.indexSettings().getSettings());
68+
if (indexShard.getReplicationGroup().getRoutingTable().unpromotableShards().size() > 0 && fastRefresh == false) {
69+
sendUnpromotableRequests(indexShard, r.generation(), true, l, postWriteRefreshTimeout);
70+
} else {
71+
l.onResponse(true);
7572
}
76-
77-
@Override
78-
public void onFailure(Exception e) {
79-
listener.onFailure(e);
80-
}
81-
});
73+
}));
8274
default -> throw new IllegalArgumentException("unknown refresh policy: " + policy);
8375
}
8476
}

0 commit comments

Comments
 (0)