diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java index 829d3ef640..b0eb99c808 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocolPB/PBHelperClient.java @@ -2265,7 +2265,7 @@ public static DataEncryptionKeyProto convert(DataEncryptionKey bet) { public static FsServerDefaultsProto convert(FsServerDefaults fs) { if (fs == null) return null; - return FsServerDefaultsProto.newBuilder(). + FsServerDefaultsProto.Builder builder = FsServerDefaultsProto.newBuilder(). setBlockSize(fs.getBlockSize()). setBytesPerChecksum(fs.getBytesPerChecksum()). setWritePacketSize(fs.getWritePacketSize()) @@ -2274,9 +2274,11 @@ public static FsServerDefaultsProto convert(FsServerDefaults fs) { .setEncryptDataTransfer(fs.getEncryptDataTransfer()) .setTrashInterval(fs.getTrashInterval()) .setChecksumType(convert(fs.getChecksumType())) - .setKeyProviderUri(fs.getKeyProviderUri()) - .setPolicyId(fs.getDefaultStoragePolicyId()) - .build(); + .setPolicyId(fs.getDefaultStoragePolicyId()); + if (fs.getKeyProviderUri() != null) { + builder.setKeyProviderUri(fs.getKeyProviderUri()); + } + return builder.build(); } public static EnumSetWritable convertCreateFlag(int flag) {