From 1f6f81d840420b32a1cfb22ff9002b39316e2f1b Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Wed, 29 Feb 2012 16:43:30 +0200 Subject: [PATCH] NullPointerException when asking for null valued json field when fetching search request, closes #1749. --- .../common/xcontent/support/XContentMapConverter.java | 4 ++++ 1 file changed, 4 insertions(+) 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);