HDFS-4369. GetBlockKeysResponseProto does not handle null response. Contributed by Suresh Srinivas.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1433206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-01-14 23:13:27 +00:00
parent 0671176111
commit 6dbc7e03e5
4 changed files with 13 additions and 5 deletions

View File

@ -311,6 +311,8 @@ Release 2.0.3-alpha - Unreleased
HDFS-4364. GetLinkTargetResponseProto does not handle null path. (suresh)
HDFS-4369. GetBlockKeysResponseProto does not handle null response.
(suresh)
NEW FEATURES

View File

@ -91,8 +91,12 @@ public GetBlockKeysResponseProto getBlockKeys(RpcController unused,
} catch (IOException e) {
throw new ServiceException(e);
}
return GetBlockKeysResponseProto.newBuilder()
.setKeys(PBHelper.convert(keys)).build();
GetBlockKeysResponseProto.Builder builder =
GetBlockKeysResponseProto.newBuilder();
if (keys != null) {
builder.setKeys(PBHelper.convert(keys));
}
return builder.build();
}
@Override

View File

@ -29,6 +29,7 @@
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.ErrorReportRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlockKeysRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlockKeysResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlocksRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetEditLogManifestRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetMostRecentCheckpointTxIdRequestProto;
@ -104,8 +105,9 @@ public BlocksWithLocations getBlocks(DatanodeInfo datanode, long size)
@Override
public ExportedBlockKeys getBlockKeys() throws IOException {
try {
return PBHelper.convert(rpcProxy.getBlockKeys(NULL_CONTROLLER,
GET_BLOCKKEYS).getKeys());
GetBlockKeysResponseProto rsp = rpcProxy.getBlockKeys(NULL_CONTROLLER,
GET_BLOCKKEYS);
return rsp.hasKeys() ? PBHelper.convert(rsp.getKeys()) : null;
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}

View File

@ -56,7 +56,7 @@ message GetBlockKeysRequestProto {
* keys - Information about block keys at the active namenode
*/
message GetBlockKeysResponseProto {
required ExportedBlockKeysProto keys = 1;
optional ExportedBlockKeysProto keys = 1;
}
/**