Skip to content

Commit 171d7c4

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

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
@@ -764,7 +764,7 @@ void sendReleaseSearchContext(ShardSearchContextId contextId, Transport.Connecti
764764
* @see #onShardFailure(int, SearchShardTarget, Exception)
765765
* @see #onShardResult(SearchPhaseResult, SearchShardIterator)
766766
*/
767-
final void onPhaseDone() { // as a tribute to @kimchy aka. finishHim()
767+
private void onPhaseDone() { // as a tribute to @kimchy aka. finishHim()
768768
executeNextPhase(this, this::getNextPhase);
769769
}
770770

@@ -792,13 +792,6 @@ public final void execute(Runnable command) {
792792
executor.execute(command);
793793
}
794794

795-
/**
796-
* Notifies the top-level listener of the provided exception
797-
*/
798-
public void onFailure(Exception e) {
799-
listener.onFailure(e);
800-
}
801-
802795
/**
803796
* Builds an request for the initial search phase.
804797
*

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)