[SCRIPTS] GetIndexedScript call can deadlock
GetIndexedScript can deadlock since they perform blocking operation on the network thread. This commit moves the blocking to an async operation
This commit is contained in:
parent
e3a09e1933
commit
bf1aed14db
|
@ -49,8 +49,18 @@ public class TransportGetIndexedScriptAction extends HandledTransportAction<GetI
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doExecute(GetIndexedScriptRequest request, ActionListener<GetIndexedScriptResponse> listener){
|
||||
GetResponse scriptResponse = scriptService.queryScriptIndex(request);
|
||||
listener.onResponse(new GetIndexedScriptResponse(scriptResponse));
|
||||
public void doExecute(GetIndexedScriptRequest request, final ActionListener<GetIndexedScriptResponse> listener){
|
||||
// forward the handling to the script service we are running on a network thread here...
|
||||
scriptService.queryScriptIndex(request,new ActionListener<GetResponse>() {
|
||||
@Override
|
||||
public void onResponse(GetResponse getFields) {
|
||||
listener.onResponse(new GetIndexedScriptResponse(getFields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
listener.onFailure(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -354,12 +354,12 @@ public class ScriptService extends AbstractComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public GetResponse queryScriptIndex(GetIndexedScriptRequest request) {
|
||||
public void queryScriptIndex(GetIndexedScriptRequest request, final ActionListener<GetResponse> 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) {
|
||||
|
|
Loading…
Reference in New Issue