[SSHD-663] Wrong if criteria in org.apache.sshd.common.file.util.ImmutableList.subList()

Removed the class altogether
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java
index 73e1750..11ff32e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java
@@ -44,7 +44,6 @@
 import org.apache.sshd.client.session.ClientSessionHolder;
 import org.apache.sshd.common.PropertyResolverUtils;
 import org.apache.sshd.common.file.util.BaseFileSystem;
-import org.apache.sshd.common.file.util.ImmutableList;
 import org.apache.sshd.common.subsystem.sftp.SftpConstants;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
@@ -142,7 +141,7 @@
     }
 
     @Override
-    protected SftpPath create(String root, ImmutableList<String> names) {
+    protected SftpPath create(String root, List<String> names) {
         return new SftpPath(this, root, names);
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpPath.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpPath.java
index d2f33ce..5567b58 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpPath.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpPath.java
@@ -22,12 +22,12 @@
 import java.nio.file.FileSystem;
 import java.nio.file.LinkOption;
 import java.nio.file.spi.FileSystemProvider;
+import java.util.List;
 
 import org.apache.sshd.common.file.util.BasePath;
-import org.apache.sshd.common.file.util.ImmutableList;
 
 public class SftpPath extends BasePath<SftpPath, SftpFileSystem> {
-    public SftpPath(SftpFileSystem fileSystem, String root, ImmutableList<String> names) {
+    public SftpPath(SftpFileSystem fileSystem, String root, List<String> names) {
         super(fileSystem, root, names);
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
index 974667a..7ded64e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
@@ -23,11 +23,11 @@
 import java.nio.file.FileSystem;
 import java.nio.file.Path;
 import java.nio.file.attribute.UserPrincipalLookupService;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.sshd.common.file.util.BaseFileSystem;
-import org.apache.sshd.common.file.util.ImmutableList;
 import org.apache.sshd.common.util.ValidateUtils;
 
 /**
@@ -85,7 +85,7 @@
     }
 
     @Override
-    protected RootedPath create(String root, ImmutableList<String> names) {
+    protected RootedPath create(String root, List<String> names) {
         return new RootedPath(this, root, names);
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
index d89828c..e708aed 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
@@ -24,15 +24,15 @@
 import java.nio.file.LinkOption;
 import java.nio.file.Path;
 import java.nio.file.spi.FileSystemProvider;
+import java.util.List;
 
 import org.apache.sshd.common.file.util.BasePath;
-import org.apache.sshd.common.file.util.ImmutableList;
 
 /**
  * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
  */
 public class RootedPath extends BasePath<RootedPath, RootedFileSystem> {
-    public RootedPath(RootedFileSystem fileSystem, String root, ImmutableList<String> names) {
+    public RootedPath(RootedFileSystem fileSystem, String root, List<String> names) {
         super(fileSystem, root, names);
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
index 88c7c73..8d69916 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
@@ -28,6 +28,7 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -246,13 +247,12 @@
     }
 
     protected T create(String root, String... names) {
-        return create(root, new ImmutableList<>(names));
+        return create(root, GenericUtils.unmodifiableList(names));
     }
 
     protected T create(String root, Collection<String> names) {
-        return create(root, new ImmutableList<>(names.toArray(new String[names.size()])));
+        return create(root, GenericUtils.unmodifiableList(names));
     }
 
-    protected abstract T create(String root, ImmutableList<String> names);
-
+    protected abstract T create(String root, List<String> names);
 }
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
index 5f59626..5e42099 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
@@ -43,12 +43,12 @@
 public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSystem<T>> implements Path {
 
     protected final String root;
-    protected final ImmutableList<String> names;
+    protected final List<String> names;
     private final FS fileSystem;
     private String strValue;
     private int hashValue;
 
-    public BasePath(FS fileSystem, String root, ImmutableList<String> names) {
+    public BasePath(FS fileSystem, String root, List<String> names) {
         this.fileSystem = ValidateUtils.checkNotNull(fileSystem, "No file system provided");
         this.root = root;
         this.names = names;
@@ -60,14 +60,14 @@
     }
 
     protected T create(String root, String... names) {
-        return create(root, new ImmutableList<>(names));
+        return create(root, GenericUtils.unmodifiableList(names));
     }
 
     protected T create(String root, Collection<String> names) {
-        return create(root, new ImmutableList<>(names.toArray(new String[names.size()])));
+        return create(root, GenericUtils.unmodifiableList(names));
     }
 
-    protected T create(String root, ImmutableList<String> names) {
+    protected T create(String root, List<String> names) {
         return fileSystem.create(root, names);
     }
 
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java
deleted file mode 100644
index f126c41..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/ImmutableList.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file.util;
-
-import java.util.AbstractList;
-
-/**
- * Simple immutable array list
- *
- * @param <T> The element type
- */
-public class ImmutableList<T> extends AbstractList<T> {
-
-    private final T[] data;
-    private final int from;
-    private final int to;
-
-    public ImmutableList(T[] data) {
-        this(data, 0, data.length);
-    }
-
-    public ImmutableList(T[] data, int from, int to) {
-        this.data = data;
-        this.from = from;
-        this.to = to;
-    }
-
-    @Override
-    public T get(int index) {
-        return data[from + index];
-    }
-
-    @Override
-    public int size() {
-        return to - from;
-    }
-
-    @Override
-    public ImmutableList<T> subList(int fromIndex, int toIndex) {
-        if (fromIndex == from && toIndex == to) {
-            return this;
-        }
-        return new ImmutableList<>(data, from + fromIndex, from + toIndex);
-    }
-
-}
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
index 01743ff..3b23895 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
@@ -284,6 +284,19 @@
     }
 
     @SafeVarargs
+    public static <T> List<T> unmodifiableList(T ... values) {
+        return unmodifiableList(asList(values));
+    }
+
+    public static <T> List<T> unmodifiableList(Collection<? extends T> values) {
+        if (isEmpty(values)) {
+            return Collections.emptyList();
+        } else {
+            return Collections.unmodifiableList(new ArrayList<T>(values));
+        }
+    }
+
+    @SafeVarargs
     public static <T> List<T> asList(T ... values) {
         int len = length(values);
         if (len <= 0) {
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java b/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
index a9fddc3..5d69f0a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
@@ -28,9 +28,11 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.util.test.BaseTestSupport;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
@@ -334,7 +336,7 @@
         }
 
         @Override
-        protected TestPath create(String root, ImmutableList<String> names) {
+        protected TestPath create(String root, List<String> names) {
             return new TestPath(this, root, names);
         }
 
@@ -361,12 +363,12 @@
 
     private static class TestPath extends BasePath<TestPath, TestFileSystem> {
 
-        TestPath(TestFileSystem fileSystem, String root, ImmutableList<String> names) {
+        TestPath(TestFileSystem fileSystem, String root, List<String> names) {
             super(fileSystem, root, names);
         }
 
         @Override
-        protected TestPath create(String root, ImmutableList<String> names) {
+        protected TestPath create(String root, List<String> names) {
             return new TestPath(getFileSystem(), root, names);
         }
 
@@ -386,7 +388,7 @@
         private final FileSystem fileSystem;
         private final String string;
         private String root;
-        private ImmutableList<String> names = new ImmutableList<>(new String[0]);
+        private List<String> names = Collections.<String>emptyList();
 
         public PathTester(FileSystem fileSystem, String string) {
             this.fileSystem = fileSystem;
@@ -399,7 +401,7 @@
         }
 
         public PathTester names(Collection<String> names) {
-            this.names = new ImmutableList<>(names.toArray(new String[names.size()]));
+            this.names = GenericUtils.unmodifiableList(names);
             return this;
         }