From f414e09d39dbb5585165b08231059f6794174927 Mon Sep 17 00:00:00 2001 From: Shrijeet Paliwal Date: Wed, 7 Dec 2011 22:03:15 -0800 Subject: [PATCH] HBASE-4980 Fix NPE in HBaseClient receiveResponse --- .../org/apache/hadoop/hbase/ipc/HBaseClient.java | 37 +++++++++---------- 1 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java index 7084a2f..8e7c2ba 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java @@ -573,25 +573,24 @@ public class HBaseClient { if (LOG.isDebugEnabled()) LOG.debug(getName() + " got value #" + id); Call call = calls.remove(id); - - // Read the flag byte - byte flag = in.readByte(); - boolean isError = ResponseFlag.isError(flag); - if (ResponseFlag.isLength(flag)) { - // Currently length if present is unused. - in.readInt(); - } - int state = in.readInt(); // Read the state. Currently unused. - if (isError) { - //noinspection ThrowableInstanceNeverThrown - call.setException(new RemoteException( WritableUtils.readString(in), - WritableUtils.readString(in))); - } else { - Writable value = ReflectionUtils.newInstance(valueClass, conf); - value.readFields(in); // read value - // it's possible that this call may have been cleaned up due to a RPC - // timeout, so check if it still exists before setting the value. - if (call != null) { + // it's possible that this call may have been cleaned up due to a RPC + // timeout, so check if it still exists before setting the value. + if (call != null) { + // Read the flag byte + byte flag = in.readByte(); + boolean isError = ResponseFlag.isError(flag); + if (ResponseFlag.isLength(flag)) { + // Currently length if present is unused. + in.readInt(); + } + int state = in.readInt(); // Read the state. Currently unused. + if (isError) { + //noinspection ThrowableInstanceNeverThrown + call.setException(new RemoteException( WritableUtils.readString(in), + WritableUtils.readString(in))); + } else { + Writable value = ReflectionUtils.newInstance(valueClass, conf); + value.readFields(in); // read value call.setValue(value); } } -- 1.7.5.4