From c6199b611e346f6f81fe5b5761650156c3d4daeb Mon Sep 17 00:00:00 2001 From: Andrew Raines Date: Tue, 24 Dec 2013 11:01:01 -0600 Subject: [PATCH] Need to make sure we always end up with a Cell, even if it's null. Fixes #4544. --- .../java/org/elasticsearch/common/Table.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/elasticsearch/common/Table.java b/src/main/java/org/elasticsearch/common/Table.java index 24956db9672..68e715857b2 100644 --- a/src/main/java/org/elasticsearch/common/Table.java +++ b/src/main/java/org/elasticsearch/common/Table.java @@ -85,18 +85,6 @@ public class Table { return this; } - public Table addCell(Cell cell) { - currentCells.add(cell); - - // If we're in a value row, also populate the named column. - if (!inHeaders) { - String hdr = (String) headers.get(currentCells.indexOf(cell)).value; - map.get(hdr).add(cell); - } - - return this; - } - public Table addCell(Object value) { return addCell(value, ""); } @@ -130,7 +118,16 @@ public class Table { mAttr.put(sAttr.substring(0, idx), sAttr.substring(idx + 1)); } } - addCell(new Cell(value, mAttr)); + + Cell cell = new Cell(value, mAttr); + currentCells.add(cell); + + // If we're in a value row, also populate the named column. + if (!inHeaders) { + String hdr = (String) headers.get(currentCells.indexOf(cell)).value; + map.get(hdr).add(cell); + } + return this; }