diff --git a/src/main/java/org/elasticsearch/action/indexedscripts/get/TransportGetIndexedScriptAction.java b/src/main/java/org/elasticsearch/action/indexedscripts/get/TransportGetIndexedScriptAction.java index d48a55b7072..6c2fbf231d8 100644 --- a/src/main/java/org/elasticsearch/action/indexedscripts/get/TransportGetIndexedScriptAction.java +++ b/src/main/java/org/elasticsearch/action/indexedscripts/get/TransportGetIndexedScriptAction.java @@ -49,8 +49,18 @@ public class TransportGetIndexedScriptAction extends HandledTransportAction listener){ - GetResponse scriptResponse = scriptService.queryScriptIndex(request); - listener.onResponse(new GetIndexedScriptResponse(scriptResponse)); + public void doExecute(GetIndexedScriptRequest request, final ActionListener listener){ + // forward the handling to the script service we are running on a network thread here... + scriptService.queryScriptIndex(request,new ActionListener() { + @Override + public void onResponse(GetResponse getFields) { + listener.onResponse(new GetIndexedScriptResponse(getFields)); + } + + @Override + public void onFailure(Throwable e) { + listener.onFailure(e); + } + }); } } diff --git a/src/main/java/org/elasticsearch/script/ScriptService.java b/src/main/java/org/elasticsearch/script/ScriptService.java index 06736d2b345..10017de3efb 100644 --- a/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/src/main/java/org/elasticsearch/script/ScriptService.java @@ -354,12 +354,12 @@ public class ScriptService extends AbstractComponent { } } - public GetResponse queryScriptIndex(GetIndexedScriptRequest request) { + public void queryScriptIndex(GetIndexedScriptRequest request, final ActionListener listener) { String scriptLang = validateScriptLanguage(request.scriptLang()); GetRequest getRequest = new GetRequest(request, SCRIPT_INDEX).type(scriptLang).id(request.id()) .version(request.version()).versionType(request.versionType()) .operationThreaded(false).preference("_local"); //Set preference for no forking - return client.get(getRequest).actionGet(); + client.get(getRequest, listener); } private String validateScriptLanguage(String scriptLang) {