Remove SearchContext#current and all it's threadlocals (elastic/elasticsearch#3677)

Followup PR for elastic/elasticsearchelastic/elasticsearch#20778

Original commit: elastic/x-pack-elasticsearch@1e3959545e
This commit is contained in:
Simon Willnauer 2016-10-06 19:52:34 +02:00 committed by GitHub
parent bb8c08f254
commit 31ed371ed0
3 changed files with 5 additions and 3 deletions

View File

@ -406,7 +406,7 @@ public class SecurityIndexSearcherWrapper extends IndexSearcherWrapper {
}
};
QueryRewriteContext copy = new QueryRewriteContext(original.getIndexSettings(), original.getMapperService(), scriptService, null,
client, original.getIndexReader(), original.getClusterState());
client, original.getIndexReader(), original.getClusterState(), original::nowInMillis);
queryBuilder.rewrite(copy);
}
}

View File

@ -75,7 +75,7 @@ public class SecurityIndexSearcherWrapperIntegrationTests extends ESTestCase {
Client client = mock(Client.class);
when(client.settings()).thenReturn(Settings.EMPTY);
final long nowInMillis = randomPositiveLong();
QueryShardContext realQueryShardContext = new QueryShardContext(indexSettings, null, null, mapperService, null,
QueryShardContext realQueryShardContext = new QueryShardContext(shardId.id(), indexSettings, null, null, mapperService, null,
null, indicesQueriesRegistry, client, null, null, () -> nowInMillis);
QueryShardContext queryShardContext = spy(realQueryShardContext);
QueryParseContext queryParseContext = mock(QueryParseContext.class);

View File

@ -812,7 +812,9 @@ public class SecurityIndexSearcherWrapperUnitTests extends ESTestCase {
public void testFailIfQueryUsesClient() throws Exception {
Client client = mock(Client.class);
when(client.settings()).thenReturn(Settings.EMPTY);
QueryRewriteContext context = new QueryRewriteContext(null, mapperService, scriptService, null, client, null, null);
final long nowInMillis = randomPositiveLong();
QueryRewriteContext context = new QueryRewriteContext(null, mapperService, scriptService, null, client, null, null,
() -> nowInMillis);
QueryBuilder queryBuilder1 = new TermsQueryBuilder("field", "val1", "val2");
SecurityIndexSearcherWrapper.failIfQueryUsesClient(scriptService, queryBuilder1, context);