diff --git a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index e7c2018ad31..ec529e59ae7 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -82,7 +82,6 @@ import java.util.stream.Collectors; public class TransportBulkAction extends HandledTransportAction { private final AutoCreateIndex autoCreateIndex; - private final boolean allowIdGeneration; private final ClusterService clusterService; private final IngestService ingestService; private final TransportShardBulkAction shardBulkAction; @@ -115,7 +114,6 @@ public class TransportBulkAction extends HandledTransportAction implement } - public void process(@Nullable MappingMetaData mappingMd, boolean allowIdGeneration, String concreteIndex) { + public void process(@Nullable MappingMetaData mappingMd, String concreteIndex) { if (mappingMd != null) { // might as well check for routing here if (mappingMd.routing().required() && routing == null) { @@ -542,9 +542,9 @@ public class IndexRequest extends ReplicatedWriteRequest implement } } - // generate id if not already provided and id generation is allowed - if (allowIdGeneration && id == null) { - assert autoGeneratedTimestamp == -1; + // generate id if not already provided + if (id == null) { + assert autoGeneratedTimestamp == -1 : "timestamp has already been generated!"; autoGeneratedTimestamp = Math.max(0, System.currentTimeMillis()); // extra paranoia id(UUIDs.base64UUID()); } diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index 034ad915d04..55d51a42677 100644 --- a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -122,10 +122,10 @@ public class IndexRequestTests extends ESTestCase { public void testAutoGenIdTimestampIsSet() { IndexRequest request = new IndexRequest("index", "type"); - request.process(null, true, "index"); + request.process(null, "index"); assertTrue("expected > 0 but got: " + request.getAutoGeneratedTimestamp(), request.getAutoGeneratedTimestamp() > 0); request = new IndexRequest("index", "type", "1"); - request.process(null, true, "index"); + request.process(null, "index"); assertEquals(IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP, request.getAutoGeneratedTimestamp()); } diff --git a/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java b/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java index 681a3758ea7..0a0cddf5d81 100644 --- a/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java @@ -490,7 +490,7 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase IndexingAction(IndexRequest request, ActionListener listener, ReplicationGroup replicationGroup) { super(request, listener, replicationGroup, "indexing"); - request.process(null, true, request.index()); + request.process(null, request.index()); } @Override