steveloughran commented on code in PR #6739:
URL: https://github.com/apache/hadoop/pull/6739#discussion_r1581033141


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoUtils.java:
##########
@@ -55,15 +58,18 @@ public static String getJceProvider(Configuration conf) {
         
CommonConfigurationKeysPublic.HADOOP_SECURITY_CRYPTO_JCE_PROVIDER_AUTO_ADD_KEY,
         
CommonConfigurationKeysPublic.HADOOP_SECURITY_CRYPTO_JCE_PROVIDER_AUTO_ADD_DEFAULT);
 
-    // For backward compatible, auto-add BOUNCY_CASTLE_PROVIDER_CLASS.
-    if (autoAdd && !provider.isEmpty()) {
+    // For backward compatible, auto-add BOUNCY_CASTLE_PROVIDER_CLASS when the 
provider is "BC".
+    if (autoAdd && PROVIDER_NAME.equals(provider)) {
       try {
         // Use reflection in order to avoid statically loading the class.
         final Class<?> clazz = Class.forName(BOUNCY_CASTLE_PROVIDER_CLASS);
-        final Field provider_name = clazz.getField("PROVIDER_NAME");
-        if (provider.equals(provider_name.get(null))) {
+        final Field providerName = clazz.getField("PROVIDER_NAME");

Review Comment:
   I dont think this is needed any more. If it is, use the constant 
`PROVIDER_NAME_FIELD`, but really, given we know what string we are looking 
for, no need to ask for the field or check it again



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoUtils.java:
##########
@@ -40,6 +41,8 @@ public class CryptoUtils {
       = "org.bouncycastle.jce.provider.BouncyCastleProvider";
   private static final String PROVIDER_NAME_FIELD = "PROVIDER_NAME";
 
+  static final String PROVIDER_NAME = "BC";

Review Comment:
   make private add a javadoc, and give it a name like 
BOUNCY_CASTLE_PROVIDER_NAME



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to