Skip to content

Commit a77a389

Browse files
committed
poorly formatted properties should return 400
1 parent 6d8c5fb commit a77a389

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.action.admin.indices.create;
1111

12+
import org.apache.logging.log4j.LogManager;
13+
import org.apache.logging.log4j.Logger;
1214
import org.elasticsearch.ElasticsearchGenerationException;
1315
import org.elasticsearch.ElasticsearchParseException;
1416
import org.elasticsearch.TransportVersions;
@@ -54,6 +56,7 @@
5456
* @see CreateIndexResponse
5557
*/
5658
public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest> implements IndicesRequest {
59+
protected final Logger logger = LogManager.getLogger(getClass());
5760

5861
public static final ParseField MAPPINGS = new ParseField("mappings");
5962
public static final ParseField SETTINGS = new ParseField("settings");
@@ -310,11 +313,16 @@ private CreateIndexRequest mapping(String type, Map<String, ?> source) {
310313
* @return true if the source map is empty or contains only an empty "properties" key, false otherwise
311314
*/
312315
private boolean isSourceEffectivelyEmpty(Map<String, ?> source) {
316+
if (source == null) {
317+
return true;
318+
}
313319
if (source.isEmpty()) {
314320
return true;
315321
}
316322
if (source.size() == 1 && source.containsKey("properties")) {
317-
return ((Map<?, ?>) source.get("properties")).isEmpty();
323+
if (source.get("properties") instanceof Map<?,?> properties) {
324+
return properties.isEmpty();
325+
}
318326
}
319327
return false;
320328
}

0 commit comments

Comments
 (0)