only set the client instance once in the proxy

Original commit: elastic/x-pack-elasticsearch@55eb6288db
This commit is contained in:
jaymode 2016-01-27 14:24:41 -05:00
parent 7645698070
commit 634b3edf4e
1 changed files with 3 additions and 2 deletions

View File

@ -70,9 +70,8 @@ public class ClientProxy implements InitializingService.Initializable {
@Override @Override
public void init(Injector injector) { public void init(Injector injector) {
client = injector.getInstance(Client.class);
if (shieldIntegration != null) { if (shieldIntegration != null) {
client = new FilterClient(client) { this.client = new FilterClient(injector.getInstance(Client.class)) {
@Override @Override
protected <Request extends ActionRequest<Request>, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void doExecute(Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) { protected <Request extends ActionRequest<Request>, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void doExecute(Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
try (ThreadContext.StoredContext ctx = threadPool().getThreadContext().stashContext()) { try (ThreadContext.StoredContext ctx = threadPool().getThreadContext().stashContext()) {
@ -81,6 +80,8 @@ public class ClientProxy implements InitializingService.Initializable {
} }
} }
}; };
} else {
this.client = injector.getInstance(Client.class);
} }
} }