From b349cd9d0b369129777a4eaba0a9d74da44ece1f Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Thu, 15 Jan 2015 21:27:39 +0900 Subject: [PATCH] YARN-3005. [JDK7] Use switch statement for String instead of if-else statement in RegistrySecurity.java (Contributed by Kengo Seki) (cherry picked from commit 533e551eb42af188535aeb0ab35f8ebf150a0da1) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../registry/client/impl/zk/RegistrySecurity.java | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 6ab31345228..92dc3bd3970 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -46,6 +46,9 @@ Release 2.7.0 - UNRELEASED IMPROVEMENTS + YARN-3005. [JDK7] Use switch statement for String instead of if-else + statement in RegistrySecurity.java (Kengo Seki via aajisaka) + YARN-2950. Change message to mandate, not suggest JS requirement on UI. (Dustin Cote via harsh) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java index d3c2d15de53..1c75e43987e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java @@ -192,14 +192,17 @@ public class RegistrySecurity extends AbstractService { String auth = conf.getTrimmed(KEY_REGISTRY_CLIENT_AUTH, REGISTRY_CLIENT_AUTH_ANONYMOUS); - // TODO JDK7 SWITCH - if (REGISTRY_CLIENT_AUTH_KERBEROS.equals(auth)) { + switch (auth) { + case REGISTRY_CLIENT_AUTH_KERBEROS: access = AccessPolicy.sasl; - } else if (REGISTRY_CLIENT_AUTH_DIGEST.equals(auth)) { + break; + case REGISTRY_CLIENT_AUTH_DIGEST: access = AccessPolicy.digest; - } else if (REGISTRY_CLIENT_AUTH_ANONYMOUS.equals(auth)) { + break; + case REGISTRY_CLIENT_AUTH_ANONYMOUS: access = AccessPolicy.anon; - } else { + break; + default: throw new ServiceStateException(E_UNKNOWN_AUTHENTICATION_MECHANISM + "\"" + auth + "\""); }