diff --git a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java index 12b2da120f63e..c5dcfe5588ca6 100644 --- a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java +++ b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java @@ -309,10 +309,10 @@ private ParsedQuery toQuery(QueryBuilder queryBuilder, CheckedFunction context.toQuery(new AbstractQueryBuilder() { + @Override + public String getWriteableName() { + return null; + } + + @Override + protected void doWriteTo(StreamOutput out) throws IOException { + + } + + @Override + protected void doXContent(XContentBuilder builder, Params params) throws IOException { + + } + + @Override + protected Query doToQuery(QueryShardContext context) throws IOException { + throw new RuntimeException("boom"); + } + + @Override + protected boolean doEquals(AbstractQueryBuilder other) { + return false; + } + + @Override + protected int doHashCode() { + return 0; + } + })); + assertThat(exc.getMessage(), equalTo("failed to create query: boom")); + } + public void testClusterAlias() throws IOException { final String clusterAlias = randomBoolean() ? null : "remote_cluster"; QueryShardContext context = createQueryShardContext(IndexMetaData.INDEX_UUID_NA_VALUE, clusterAlias);