diff --git a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java index afaaea02030..ef245073dcf 100644 --- a/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java +++ b/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapConverter.java @@ -146,6 +146,10 @@ public class XContentMapConverter { } private static void writeValue(XContentGenerator gen, Object value) throws IOException { + if (value == null) { + gen.writeNull(); + return; + } Class type = value.getClass(); if (type == String.class) { gen.writeString((String) value);