Skip to content

Commit 4e8e973

Browse files
Remove some dead code from SearchPhase and friends (#116645)
The separate `onFailure` is unnecessary, just fail the phase like we do elsewhere. Also make utility method static.
1 parent 9df4a49 commit 4e8e973

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

server/src/main/java/org/elasticsearch/action/search/AbstractSearchAsyncAction.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ void sendReleaseSearchContext(ShardSearchContextId contextId, Transport.Connecti
739739
* @see #onShardFailure(int, SearchShardTarget, Exception)
740740
* @see #onShardResult(SearchPhaseResult, SearchShardIterator)
741741
*/
742-
final void onPhaseDone() { // as a tribute to @kimchy aka. finishHim()
742+
private void onPhaseDone() { // as a tribute to @kimchy aka. finishHim()
743743
executeNextPhase(this, this::getNextPhase);
744744
}
745745

@@ -762,13 +762,6 @@ public final void execute(Runnable command) {
762762
executor.execute(command);
763763
}
764764

765-
/**
766-
* Notifies the top-level listener of the provided exception
767-
*/
768-
public void onFailure(Exception e) {
769-
listener.onFailure(e);
770-
}
771-
772765
/**
773766
* Builds an request for the initial search phase.
774767
*

server/src/main/java/org/elasticsearch/action/search/ExpandSearchPhase.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private void doRun() {
102102
for (InnerHitBuilder innerHitBuilder : innerHitBuilders) {
103103
MultiSearchResponse.Item item = it.next();
104104
if (item.isFailure()) {
105-
context.onPhaseFailure(this, "failed to expand hits", item.getFailure());
105+
phaseFailure(item.getFailure());
106106
return;
107107
}
108108
SearchHits innerHits = item.getResponse().getHits();
@@ -119,7 +119,11 @@ private void doRun() {
119119
}
120120
}
121121
onPhaseDone();
122-
}, context::onFailure));
122+
}, this::phaseFailure));
123+
}
124+
125+
private void phaseFailure(Exception ex) {
126+
context.onPhaseFailure(this, "failed to expand hits", ex);
123127
}
124128

125129
private static SearchSourceBuilder buildExpandSearchSourceBuilder(InnerHitBuilder options, CollapseBuilder innerCollapseBuilder) {

server/src/test/java/org/elasticsearch/action/search/MockSearchPhaseContext.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,6 @@ protected void executePhaseOnShard(
154154
}, shardIt);
155155
}
156156

157-
@Override
158-
public void onFailure(Exception e) {
159-
Assert.fail("should not be called");
160-
}
161-
162157
@Override
163158
public void sendReleaseSearchContext(ShardSearchContextId contextId, Transport.Connection connection, OriginalIndices originalIndices) {
164159
releasedSearchContexts.add(contextId);

0 commit comments

Comments
 (0)