From ad32759fd9f33e7bd18758ad1a5a464dab3bcbd9 Mon Sep 17 00:00:00 2001 From: Wei-Chiu Chuang Date: Tue, 5 Sep 2017 15:11:37 -0700 Subject: [PATCH] HADOOP-14688. Intern strings in KeyVersion and EncryptedKeyVersion. Contributed by Xiao Chen. --- .../main/java/org/apache/hadoop/crypto/key/KeyProvider.java | 4 ++-- .../apache/hadoop/crypto/key/KeyProviderCryptoExtension.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java index fb3dba4331..c1c371b6a4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java @@ -71,8 +71,8 @@ public static class KeyVersion { protected KeyVersion(String name, String versionName, byte[] material) { - this.name = name; - this.versionName = versionName; + this.name = name == null ? null : name.intern(); + this.versionName = versionName == null ? null : versionName.intern(); this.material = material; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProviderCryptoExtension.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProviderCryptoExtension.java index 8c879b3c14..693c7853ed 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProviderCryptoExtension.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProviderCryptoExtension.java @@ -81,8 +81,9 @@ public static class EncryptedKeyVersion { protected EncryptedKeyVersion(String keyName, String encryptionKeyVersionName, byte[] encryptedKeyIv, KeyVersion encryptedKeyVersion) { - this.encryptionKeyName = keyName; - this.encryptionKeyVersionName = encryptionKeyVersionName; + this.encryptionKeyName = keyName == null ? null : keyName.intern(); + this.encryptionKeyVersionName = encryptionKeyVersionName == null ? + null : encryptionKeyVersionName.intern(); this.encryptedKeyIv = encryptedKeyIv; this.encryptedKeyVersion = encryptedKeyVersion; }