From 02022f99315a204b7ebfac3ccece5d913f373518 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Fri, 7 Dec 2007 23:26:30 +0000 Subject: [PATCH] HADOOP-2380 REST servlet throws NPE when any value node has an empty string git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@602267 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 +++- .../org/apache/hadoop/hbase/rest/TableHandler.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index af507998fcb..8b0ca17887f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,7 +11,7 @@ Trunk (unreleased changes) HADOOP-2084 Add a LocalHBaseCluster HADOOP-2068 RESTful interface (Bryan Duxbury via Stack) HADOOP-2316 Run REST servlet outside of master - (Bryan Duxbury via Stack) + (Bryan Duxbury & Stack) OPTIMIZATIONS @@ -61,6 +61,8 @@ Trunk (unreleased changes) HADOOP-2365 Result of HashFunction.hash() contains all identical values HADOOP-2362 Leaking hdfs file handle on region split HADOOP-2338 Fix NullPointerException in master server. + HADOOP-2380 REST servlet throws NPE when any value node has an empty string + (Bryan Duxbury via Stack) IMPROVEMENTS HADOOP-2401 Add convenience put method that takes writable diff --git a/src/java/org/apache/hadoop/hbase/rest/TableHandler.java b/src/java/org/apache/hadoop/hbase/rest/TableHandler.java index ebf21346cbf..acc3ce8eb46 100644 --- a/src/java/org/apache/hadoop/hbase/rest/TableHandler.java +++ b/src/java/org/apache/hadoop/hbase/rest/TableHandler.java @@ -308,8 +308,16 @@ public class TableHandler extends GenericHandler { Node value_node = column.getElementsByTagName("value").item(0); - // decode the base64'd value - byte[] value = org.apache.hadoop.hbase.util.Base64.decode(value_node.getFirstChild().getNodeValue()); + byte[] value = new byte[0]; + + // for some reason there's no value here. probably indicates that + // the consumer passed a null as the cell value. + if(value_node.getFirstChild() != null && + value_node.getFirstChild().getNodeValue() != null){ + // decode the base64'd value + value = org.apache.hadoop.hbase.util.Base64.decode( + value_node.getFirstChild().getNodeValue()); + } // put the value table.put(lock_id, name, value);