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

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

View File

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

View File

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

View File

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

View File

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