directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject directory-kerby git commit: Changed some methods to return empty collections instead of null
Date Wed, 28 Jun 2017 09:45:32 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/trunk b0ccb42cb -> d1f1bcdd4


Changed some methods to return empty collections instead of null


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/d1f1bcdd
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/d1f1bcdd
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/d1f1bcdd

Branch: refs/heads/trunk
Commit: d1f1bcdd4c05172016a6c4933a199cf394da6b82
Parents: b0ccb42
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Jun 28 10:45:18 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Jun 28 10:45:18 2017 +0100

----------------------------------------------------------------------
 .../kerby/kerberos/kerb/client/ClientUtil.java  |  2 +-
 .../kerby/kerberos/kerb/client/KrbConfig.java   | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d1f1bcdd/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
index 004675c..a78e19c 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
@@ -206,7 +206,7 @@ public final class ClientUtil {
         if (realm != null) {
             KrbConfig krbConfig = krbSetting.getKrbConfig();
             List<Object> kdcs = krbConfig.getRealmSectionItems(realm, "kdc");
-            if (kdcs != null) {
+            if (!kdcs.isEmpty()) {
                 for (Object object : kdcs) {
                     kdcList.add(object != null ? object.toString() : null);
                 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/d1f1bcdd/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
index 9a75527..dffea68 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
@@ -24,6 +24,7 @@ import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -318,13 +319,14 @@ public class KrbConfig extends Krb5Conf {
 
     public List<Object> getRealmSectionItems(String realm, String key) {
         Map<String, Object> map = getRealmSection(realm);
-        List<Object> items = null;
-        if (map != null) {
-            items = new ArrayList<>();
-            for (Map.Entry<String, Object> entry : map.entrySet()) {
-                if (entry.getKey().equals(key)) {
-                    items.add(entry.getValue());
-                }
+        if (map.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        List<Object> items = new ArrayList<>();
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
+            if (entry.getKey().equals(key)) {
+                items.add(entry.getValue());
             }
         }
         return items;
@@ -339,9 +341,7 @@ public class KrbConfig extends Krb5Conf {
                     return (Map) entry.getValue();
                 }
             }
-            return null;
-        } else {
-            return null;
         }
+        return Collections.emptyMap();
     }
 }


Mime
View raw message