HDFS-4364. GetLinkTargetResponseProto does not handle null path. Contributed by Suresh Srinivas.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1433202 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-01-14 23:10:54 +00:00
parent f2c7de8f4e
commit 303cf8fa39
4 changed files with 13 additions and 4 deletions

View File

@ -13,6 +13,9 @@ Release 2.0.3-alpha - Unreleased
HDFS-4367. GetDataEncryptionKeyResponseProto does not handle null
response. (suresh)
HDFS-4364. GetLinkTargetResponseProto does not handle null path. (suresh)
NEW FEATURES
HDFS-2656. Add libwebhdfs, a pure C client based on WebHDFS.

View File

@ -729,8 +729,12 @@ public class ClientNamenodeProtocolServerSideTranslatorPB implements
GetLinkTargetRequestProto req) throws ServiceException {
try {
String result = server.getLinkTarget(req.getPath());
return GetLinkTargetResponseProto.newBuilder().setTargetPath(result)
.build();
GetLinkTargetResponseProto.Builder builder = GetLinkTargetResponseProto
.newBuilder();
if (result != null) {
builder.setTargetPath(result);
}
return builder.build();
} catch (IOException e) {
throw new ServiceException(e);
}

View File

@ -74,6 +74,7 @@ import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetFil
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetFileLinkInfoResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetFsStatusRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetLinkTargetRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetLinkTargetResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetListingRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetListingResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos.GetPreferredBlockSizeRequestProto;
@ -714,7 +715,8 @@ public class ClientNamenodeProtocolTranslatorPB implements
GetLinkTargetRequestProto req = GetLinkTargetRequestProto.newBuilder()
.setPath(path).build();
try {
return rpcProxy.getLinkTarget(null, req).getTargetPath();
GetLinkTargetResponseProto rsp = rpcProxy.getLinkTarget(null, req);
return rsp.hasTargetPath() ? rsp.getTargetPath() : null;
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}

View File

@ -387,7 +387,7 @@ message GetLinkTargetRequestProto {
required string path = 1;
}
message GetLinkTargetResponseProto {
required string targetPath = 1;
optional string targetPath = 1;
}
message UpdateBlockForPipelineRequestProto {