Add version check before reading script type in UpdateRequest

This commit is contained in:
Simon Willnauer 2014-07-15 10:16:08 +02:00
parent 70bd24ed14
commit 2bac455cd0
1 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,7 @@
package org.elasticsearch.action.update;
import com.google.common.collect.Maps;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.WriteConsistencyLevel;
import org.elasticsearch.action.index.IndexRequest;
@ -610,8 +611,12 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
id = in.readString();
routing = in.readOptionalString();
script = in.readOptionalString();
if( Strings.hasLength(script)) {
scriptType = ScriptService.ScriptType.readFrom(in);
if(Strings.hasLength(script)) {
if (in.getVersion().onOrAfter(Version.V_1_3_0)) {
scriptType = ScriptService.ScriptType.readFrom(in);
} else {
scriptType = null;
}
}
scriptLang = in.readOptionalString();
scriptParams = in.readMap();