HDFS-13428. RBF: Remove LinkedList From StateStoreFileImpl.java. Contributed by 
BELUGA BEHR.

(cherry picked from commit 6a881cd842fb4eab596a386b39670ea03536891a)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4574bf9e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4574bf9e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4574bf9e

Branch: refs/heads/branch-2.9
Commit: 4574bf9ed268e23321a4142b3407e035828f58d3
Parents: 0c955fe
Author: Inigo Goiri <inigo...@apache.org>
Authored: Wed Apr 11 10:40:30 2018 -0700
Committer: Inigo Goiri <inigo...@apache.org>
Committed: Wed Apr 11 10:42:36 2018 -0700

----------------------------------------------------------------------
 .../federation/store/driver/impl/StateStoreFileImpl.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/4574bf9e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/driver/impl/StateStoreFileImpl.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/driver/impl/StateStoreFileImpl.java
 
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/driver/impl/StateStoreFileImpl.java
index 7d9ddc6..6b288b3 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/driver/impl/StateStoreFileImpl.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/driver/impl/StateStoreFileImpl.java
@@ -26,9 +26,11 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.nio.charset.StandardCharsets;
-import java.util.LinkedList;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys;
 import org.apache.hadoop.hdfs.server.federation.store.records.BaseRecord;
 import org.slf4j.Logger;
@@ -134,15 +136,16 @@ public class StateStoreFileImpl extends 
StateStoreFileBaseImpl {
 
   @Override
   protected List<String> getChildren(String path) {
-    List<String> ret = new LinkedList<>();
     File dir = new File(path);
     File[] files = dir.listFiles();
-    if (files != null) {
+    if (ArrayUtils.isNotEmpty(files)) {
+      List<String> ret = new ArrayList<>(files.length);
       for (File file : files) {
         String filename = file.getName();
         ret.add(filename);
       }
+      return ret;
     }
-    return ret;
+    return Collections.emptyList();
   }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to