Repository: mina-sshd
Updated Branches:
  refs/heads/master 0d86de538 -> 17f2d627a


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java 
b/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java
index 805dca4..bcace75 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java
@@ -59,38 +59,40 @@ import org.junit.runner.Description;
  * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
  */
 public abstract class BaseTestSupport extends Assert {
-    public static final String TEMP_SUBFOLDER_NAME="temp";
+    public static final String TEMP_SUBFOLDER_NAME = "temp";
 
     // useful test sizes for keys
     @SuppressWarnings("boxing")
     public static final List<Integer> DSS_SIZES =
-        Collections.unmodifiableList(Arrays.asList(512, 768, 1024));
+            Collections.unmodifiableList(Arrays.asList(512, 768, 1024));
     @SuppressWarnings("boxing")
     public static final List<Integer> RSA_SIZES =
             Collections.unmodifiableList(Arrays.asList(1024, 2048, 3072, 
4096));
 
-    @Rule public final TestWatcher rule = new TestWatcher() {
-            // TODO consider using a ThreadLocal storage for the start time - 
provided
-            //      the code is assured to call starting/finished on the same 
thread
-            private long startTime;
-    
-            @Override
-            protected void starting(Description description) {
-                System.out.println("\nStarting " + description.getClassName() 
+ ":" + description.getMethodName() + "...\n");
-                startTime = System.currentTimeMillis();
-            }
-    
-            @Override
-            protected void finished(Description description) {
-                long duration = System.currentTimeMillis() - startTime;
-                System.out.println("\nFinished " + description.getClassName() 
+ ":" + description.getMethodName() + " in " + duration + " ms\n");
-            }
-        };
-    @Rule public final TestName TEST_NAME_HOLDER = new TestName();
-    private File    targetFolder;
+    @Rule
+    public final TestWatcher rule = new TestWatcher() {
+        // TODO consider using a ThreadLocal storage for the start time - 
provided
+        //      the code is assured to call starting/finished on the same 
thread
+        private long startTime;
+
+        @Override
+        protected void starting(Description description) {
+            System.out.println("\nStarting " + description.getClassName() + 
":" + description.getMethodName() + "...\n");
+            startTime = System.currentTimeMillis();
+        }
+
+        @Override
+        protected void finished(Description description) {
+            long duration = System.currentTimeMillis() - startTime;
+            System.out.println("\nFinished " + description.getClassName() + 
":" + description.getMethodName() + " in " + duration + " ms\n");
+        }
+    };
+    @Rule
+    public final TestName TEST_NAME_HOLDER = new TestName();
+    private File targetFolder;
 
     protected BaseTestSupport() {
-       super();
+        super();
     }
 
     public final String getCurrentTestName() {
@@ -101,11 +103,12 @@ public abstract class BaseTestSupport extends Assert {
      * Attempts to detect the location of the Maven &quot;target&quot; folder
      * associated with the project that contains the actual class extending 
this
      * base class
+     *
      * @return The {@link File} representing the location of the 
&quot;target&quot; folder
      * @throws IllegalArgumentException If failed to detect the folder
      */
     protected File detectTargetFolder() throws IllegalStateException {
-        synchronized(TEMP_SUBFOLDER_NAME) {
+        synchronized (TEMP_SUBFOLDER_NAME) {
             if (targetFolder == null) {
                 targetFolder = 
ValidateUtils.checkNotNull(Utils.detectTargetFolder(getClass()), "Failed to 
detect target folder");
             }
@@ -168,10 +171,10 @@ public abstract class BaseTestSupport extends Assert {
         if (GenericUtils.isEmpty(params)) {
             return Collections.emptyList();
         }
-        
+
         List<Object[]> result = new ArrayList<Object[]>(params.size());
         for (Object p : params) {
-            result.add(new Object[] { p });
+            result.add(new Object[]{p});
         }
 
         return result;
@@ -192,25 +195,25 @@ public abstract class BaseTestSupport extends Assert {
         if (expected == actual) {
             return;
         }
-        
-        for (int index=0; expected.hasNext(); index++) {
+
+        for (int index = 0; expected.hasNext(); index++) {
             assertTrue(message + "[next actual index=" + index + "]", 
actual.hasNext());
-            
-            T   expValue = expected.next(), actValue = actual.next();
+
+            T expValue = expected.next(), actValue = actual.next();
             assertEquals(message + "[iterator index=" + index + "]", expValue, 
actValue);
         }
-        
+
         // once expected is exhausted make sure no more actual items left
         assertFalse(message + "[non-empty-actual]", actual.hasNext());
     }
 
-    public static Path assertHierarchyTargetFolderExists(Path folder, 
LinkOption ... options) throws IOException {
+    public static Path assertHierarchyTargetFolderExists(Path folder, 
LinkOption... options) throws IOException {
         if (Files.exists(folder, options)) {
             assertTrue("Target is an existing file instead of a folder: " + 
folder, Files.isDirectory(folder, options));
         } else {
             Files.createDirectories(folder);
         }
-        
+
         return folder;
     }
 
@@ -220,25 +223,25 @@ public abstract class BaseTestSupport extends Assert {
         } else {
             assertTrue("Failed to create hierarchy of " + 
folder.getAbsolutePath(), folder.mkdirs());
         }
-        
+
         return folder;
     }
-    
+
     public static void assertObjectInstanceOf(String message, Class<?> 
expected, Object obj) {
         assertNotNull(message + " - no actual object", obj);
-        
-        Class<?>    actual=obj.getClass();
+
+        Class<?> actual = obj.getClass();
         if (!expected.isAssignableFrom(actual)) {
             fail(message + " - actual object type (" + actual.getName() + ") 
incompatible with expected (" + expected.getName() + ")");
         }
     }
-    
+
     public static <E> void assertListEquals(String message, List<? extends E> 
expected, List<? extends E> actual) {
-        int expSize=GenericUtils.size(expected), 
actSize=GenericUtils.size(actual);
+        int expSize = GenericUtils.size(expected), actSize = 
GenericUtils.size(actual);
         assertEquals(message + "[size]", expSize, actSize);
-        
-        for (int index=0; index < expSize; index++) {
-            E expValue=expected.get(index), actValue=actual.get(index);
+
+        for (int index = 0; index < expSize; index++) {
+            E expValue = expected.get(index), actValue = actual.get(index);
             assertEquals(message + "[" + index + "]", expValue, actValue);
         }
     }
@@ -273,7 +276,7 @@ public abstract class BaseTestSupport extends Assert {
         if (expected == actual) {
             return;
         }
-        
+
         assertEquals(message + "[e]", expected.getPublicExponent(), 
actual.getPublicExponent());
         assertEquals(message + "[n]", expected.getModulus(), 
actual.getModulus());
     }
@@ -282,7 +285,7 @@ public abstract class BaseTestSupport extends Assert {
         if (expected == actual) {
             return;
         }
-        
+
         assertEquals(message + "[y]", expected.getY(), actual.getY());
         assertDSAParamsEquals(message + "[params]", expected.getParams(), 
actual.getParams());
     }
@@ -300,7 +303,7 @@ public abstract class BaseTestSupport extends Assert {
         if (expected == actual) {
             return;
         }
-        
+
         assertEquals(message + "[d]", expected.getPrivateExponent(), 
actual.getPrivateExponent());
         assertEquals(message + "[n]", expected.getModulus(), 
actual.getModulus());
     }
@@ -309,7 +312,7 @@ public abstract class BaseTestSupport extends Assert {
         if (expected == actual) {
             return;
         }
-        
+
         assertEquals(message + "[x]", expected.getX(), actual.getX());
         assertDSAParamsEquals(message + "[params]", expected.getParams(), 
actual.getParams());
     }
@@ -385,8 +388,9 @@ public abstract class BaseTestSupport extends Assert {
 
     /**
      * Waits the specified timeout for the file to exist and have the required 
length
-     * @param file The file {@link Path} to check
-     * @param length Expected length
+     *
+     * @param file    The file {@link Path} to check
+     * @param length  Expected length
      * @param timeout Timeout (msec.) to wait for satisfying the requirements
      * @throws Exception If failed to access the file
      */
@@ -397,7 +401,7 @@ public abstract class BaseTestSupport extends Assert {
         assertTrue("File not found: " + file, Files.exists(file));
         assertEquals("Mismatched file size for " + file, length, 
Files.size(file));
     }
-    
+
     public static boolean waitForFile(Path file, long length, long timeout) 
throws Exception {
         while (timeout > 0L) {
             long sleepTime = Math.min(timeout, 100L);
@@ -408,11 +412,11 @@ public abstract class BaseTestSupport extends Assert {
             long sleepStart = System.nanoTime();
             Thread.sleep(sleepTime);
             long sleepEnd = System.nanoTime(), nanoSleep = sleepEnd - 
sleepStart;
-            
+
             sleepTime = TimeUnit.NANOSECONDS.toMillis(nanoSleep);
             timeout -= sleepTime;
         }
-        
+
         return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/util/BogusPasswordAuthenticator.java
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/test/java/org/apache/sshd/util/BogusPasswordAuthenticator.java 
b/sshd-core/src/test/java/org/apache/sshd/util/BogusPasswordAuthenticator.java
index 02a4889..0de7116 100644
--- 
a/sshd-core/src/test/java/org/apache/sshd/util/BogusPasswordAuthenticator.java
+++ 
b/sshd-core/src/test/java/org/apache/sshd/util/BogusPasswordAuthenticator.java
@@ -40,7 +40,7 @@ public class BogusPasswordAuthenticator extends 
AbstractLoggingBean implements P
         if (log.isDebugEnabled()) {
             log.debug("authenticate({}) {} / {} - sucess = {}", session, 
username, password, Boolean.valueOf(result));
         }
-        
+
         return result;
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java 
b/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
index aece47f..b7a2186 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
@@ -109,7 +109,7 @@ public class EchoShellFactory implements Factory<Command> {
         public void run() {
             BufferedReader r = new BufferedReader(new InputStreamReader(in));
             try {
-                for (;;) {
+                for (; ; ) {
                     String s = r.readLine();
                     if (s == null) {
                         return;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java 
b/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
index af01bc0..a51ad9a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
@@ -18,10 +18,9 @@
  */
 package org.apache.sshd.util;
 
-import org.slf4j.LoggerFactory;
-
 import com.jcraft.jsch.JSch;
 import com.jcraft.jsch.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
@@ -41,24 +40,41 @@ public class JSchLogger implements Logger {
     @Override
     public boolean isEnabled(int level) {
         switch (level) {
-            case DEBUG: return log.isDebugEnabled();
-            case INFO:  return log.isInfoEnabled();
-            case WARN:  return log.isWarnEnabled();
-            case ERROR: return log.isErrorEnabled();
-            case FATAL: return log.isErrorEnabled();
-            default   : return false;
+            case DEBUG:
+                return log.isDebugEnabled();
+            case INFO:
+                return log.isInfoEnabled();
+            case WARN:
+                return log.isWarnEnabled();
+            case ERROR:
+                return log.isErrorEnabled();
+            case FATAL:
+                return log.isErrorEnabled();
+            default:
+                return false;
         }
     }
 
     @Override
     public void log(int level, String message) {
         switch (level) {
-            case DEBUG: log.debug(message); break;
-            case INFO:  log.info(message); break;
-            case WARN:  log.warn(message); break;
-            case ERROR: log.error(message); break;
-            case FATAL: log.error(message); break;
-            default:    log.error("[LEVEL=" + level + "]: " + message);
+            case DEBUG:
+                log.debug(message);
+                break;
+            case INFO:
+                log.info(message);
+                break;
+            case WARN:
+                log.warn(message);
+                break;
+            case ERROR:
+                log.error(message);
+                break;
+            case FATAL:
+                log.error(message);
+                break;
+            default:
+                log.error("[LEVEL=" + level + "]: " + message);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java 
b/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
index 9980c4a..e8e9ae5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
@@ -66,6 +66,6 @@ public class SimpleUserInfo implements UserInfo, 
UIKeyboardInteractive {
 
     @Override
     public String[] promptKeyboardInteractive(String destination, String name, 
String instruction, String[] prompt, boolean[] echo) {
-        return new String[] { password };
+        return new String[]{password};
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/Utils.java 
b/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
index ee8139a..dfe2881 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/Utils.java
@@ -54,21 +54,22 @@ import 
org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
 public class Utils {
     // uses a cached instance to avoid re-creating the keys as it is a 
time-consuming effort
     private static final AtomicReference<KeyPairProvider> 
keyPairProviderHolder = new AtomicReference<KeyPairProvider>();
-    public static final String DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM="RSA";
+    public static final String DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM = 
"RSA";
+
     public static KeyPairProvider createTestHostKeyProvider() {
         KeyPairProvider provider = keyPairProviderHolder.get();
         if (provider != null) {
             return provider;
         }
 
-        
+
         File targetFolder = 
ValidateUtils.checkNotNull(detectTargetFolder(Utils.class), "Failed to detect 
target folder");
         File file = new File(targetFolder, "hostkey." + 
DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM.toLowerCase());
         SimpleGeneratorHostKeyProvider keyProvider = new 
SimpleGeneratorHostKeyProvider();
         keyProvider.setFile(file);
         keyProvider.setAlgorithm(DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM);
         provider = validateKeyPairProvider(keyProvider);
-        
+
         KeyPairProvider prev = keyPairProviderHolder.getAndSet(provider);
         if (prev != null) { // check if somebody else beat us to it
             return prev;
@@ -78,7 +79,8 @@ public class Utils {
     }
 
     // uses a cached instance to avoid re-creating the keys as it is a 
time-consuming effort
-    private static final Map<String, AbstractFileKeyPairProvider> providersMap 
= new ConcurrentHashMap<String, AbstractFileKeyPairProvider>(); 
+    private static final Map<String, AbstractFileKeyPairProvider> providersMap 
= new ConcurrentHashMap<String, AbstractFileKeyPairProvider>();
+
     public static AbstractFileKeyPairProvider createTestKeyPairProvider(String 
resource) {
         File file = getFile(resource);
         String filePath = file.getAbsolutePath();
@@ -103,21 +105,21 @@ public class Utils {
         ValidateUtils.checkNotNull(provider, "No provider");
 
         // get the I/O out of the way
-        Iterable<KeyPair>   
keys=ValidateUtils.checkNotNull(provider.loadKeys(), "No keys loaded");
+        Iterable<KeyPair> keys = 
ValidateUtils.checkNotNull(provider.loadKeys(), "No keys loaded");
         if (keys instanceof Collection<?>) {
             ValidateUtils.checkNotNullAndNotEmpty((Collection<?>) keys, "Empty 
keys loaded");
         }
-        
+
         return provider;
     }
-    
+
     public static Random getRandomizerInstance() {
         Factory<Random> factory = SecurityUtils.getRandomFactory();
         return factory.create();
     }
 
     public static int getFreePort() throws Exception {
-        try(ServerSocket s = new ServerSocket()) {
+        try (ServerSocket s = new ServerSocket()) {
             s.setReuseAddress(true);
             s.bind(new InetSocketAddress((InetAddress) null, 0));
             return s.getLocalPort();
@@ -128,12 +130,12 @@ public class Utils {
         URL url = Utils.class.getClassLoader().getResource(resource);
         try {
             return new File(url.toURI());
-        } catch(URISyntaxException e) {
+        } catch (URISyntaxException e) {
             return new File(url.getPath());
         }
     }
 
-    public static Path resolve(Path root, String ... children) {
+    public static Path resolve(Path root, String... children) {
         if (GenericUtils.isEmpty(children)) {
             return root;
         } else {
@@ -148,7 +150,7 @@ public class Utils {
                 path = path.resolve(child);
             }
         }
-        
+
         return path;
     }
 
@@ -156,8 +158,9 @@ public class Utils {
      * Removes the specified file - if it is a directory, then its children
      * are deleted recursively and then the directory itself. <B>Note:</B>
      * no attempt is made to make sure that {@link File#delete()} was 
successful
+     *
      * @param file The {@link File} to be deleted - ignored if {@code null}
-     * or does not exist anymore
+     *             or does not exist anymore
      * @return The <tt>file</tt> argument
      */
     public static File deleteRecursive(File file) {
@@ -178,48 +181,49 @@ public class Utils {
         if (!file.canWrite()) {
             file.setWritable(true, false);
         }
-        
+
         if (!file.delete()) {
             System.err.append("Failed to delete 
").println(file.getAbsolutePath());
         }
 
         return file;
     }
-    
+
     /**
      * Removes the specified file - if it is a directory, then its children
      * are deleted recursively and then the directory itself.
-     * @param path The file {@link Path} to be deleted - ignored if {@code 
null}
-     * or does not exist anymore
+     *
+     * @param path    The file {@link Path} to be deleted - ignored if {@code 
null}
+     *                or does not exist anymore
      * @param options The {@link LinkOption}s to use
      * @return The <tt>path</tt> argument
      * @throws IOException If failed to access/remove some file(s)
      */
-    public static Path deleteRecursive(Path path, LinkOption ... options) 
throws IOException {
+    public static Path deleteRecursive(Path path, LinkOption... options) 
throws IOException {
         if ((path == null) || (!Files.exists(path))) {
             return path;
         }
-        
+
         if (Files.isDirectory(path)) {
-            try(DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
+            try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
                 for (Path child : ds) {
                     deleteRecursive(child, options);
                 }
             }
         }
-        
+
         try {
             // seems that if a file is not writable it cannot be deleted
             if (!Files.isWritable(path)) {
                 path.toFile().setWritable(true, false);
             }
             Files.delete(path);
-        } catch(IOException e) {
+        } catch (IOException e) {
             // same logic as deleteRecursive(File) which does not check if 
deletion succeeded
             System.err.append("Failed 
(").append(e.getClass().getSimpleName()).append(")")
-                      .append(" to delete ").append(path.toString())
-                      .append(": ").println(e.getMessage())
-                      ;
+                    .append(" to delete ").append(path.toString())
+                    .append(": ").println(e.getMessage())
+            ;
         }
 
         return path;
@@ -227,8 +231,8 @@ public class Utils {
 
     /**
      * @param anchor An anchor {@link Class} whose container we want to use
-     * as the starting point for the &quot;target&quot; folder lookup up the
-     * hierarchy
+     *               as the starting point for the &quot;target&quot; folder 
lookup up the
+     *               hierarchy
      * @return The &quot;target&quot; <U>folder</U> - {@code null} if not found
      * @see #detectTargetFolder(File)
      */
@@ -242,16 +246,16 @@ public class Utils {
      * - e.g., the root folder, the containing JAR, etc.. Returns
      * {@code null} if location could not be resolved
      * @throws IllegalArgumentException If location is not a valid
-     * {@link File} location
+     *                                  {@link File} location
      * @see #getClassContainerLocationURI(Class)
      * @see #toFileSource(URI)
      */
     public static final File getClassContainerLocationFile(Class<?> clazz)
             throws IllegalArgumentException {
         try {
-            URI uri=getClassContainerLocationURI(clazz);
+            URI uri = getClassContainerLocationURI(clazz);
             return toFileSource(uri);
-        } catch(URISyntaxException | MalformedURLException e) {
+        } catch (URISyntaxException | MalformedURLException e) {
             throw new IllegalArgumentException(e.getClass().getSimpleName() + 
": " + e.getMessage(), e);
         }
     }
@@ -265,7 +269,7 @@ public class Utils {
      * @see #getClassContainerLocationURL(Class)
      */
     public static final URI getClassContainerLocationURI(Class<?> clazz) 
throws URISyntaxException {
-        URL url=getClassContainerLocationURL(clazz);
+        URL url = getClassContainerLocationURL(clazz);
         return (url == null) ? null : url.toURI();
     }
 
@@ -276,25 +280,25 @@ public class Utils {
      * {@code null} if location could not be resolved
      */
     public static final URL getClassContainerLocationURL(Class<?> clazz) {
-        ProtectionDomain    pd=clazz.getProtectionDomain();
-        CodeSource          cs=(pd == null) ? null : pd.getCodeSource();
-        URL                 url=(cs == null) ? null : cs.getLocation();
+        ProtectionDomain pd = clazz.getProtectionDomain();
+        CodeSource cs = (pd == null) ? null : pd.getCodeSource();
+        URL url = (cs == null) ? null : cs.getLocation();
         if (url == null) {
-            if ((url=getClassBytesURL(clazz)) == null) {
+            if ((url = getClassBytesURL(clazz)) == null) {
                 return null;
             }
-            
-            String  srcForm=getURLSource(url);
+
+            String srcForm = getURLSource(url);
             if (GenericUtils.isEmpty(srcForm)) {
                 return null;
             }
 
             try {
                 url = new URL(srcForm);
-            } catch(MalformedURLException e) {
+            } catch (MalformedURLException e) {
                 throw new 
IllegalArgumentException("getClassContainerLocationURL(" + clazz.getName() + ")"
-                                                 + " Failed to create URL=" + 
srcForm + " from " + url.toExternalForm()
-                                                 + ": " + e.getMessage());
+                        + " Failed to create URL=" + srcForm + " from " + 
url.toExternalForm()
+                        + ": " + e.getMessage());
             }
         }
 
@@ -305,61 +309,63 @@ public class Utils {
      * Converts a {@link URL} that may refer to an internal resource to
      * a {@link File} representing is &quot;source&quot; container (e.g.,
      * if it is a resource in a JAR, then the result is the JAR's path)
+     *
      * @param url The {@link URL} - ignored if {@code null}
      * @return The matching {@link File}
      * @throws MalformedURLException If source URL does not refer to a
-     * file location
+     *                               file location
      * @see #toFileSource(URI)
      */
     public static File toFileSource(URL url) throws MalformedURLException {
         if (url == null) {
             return null;
         }
-        
+
         try {
             return toFileSource(url.toURI());
-        } catch(URISyntaxException e) {
+        } catch (URISyntaxException e) {
             throw new MalformedURLException("toFileSource(" + 
url.toExternalForm() + ")"
-                                          + " cannot (" + 
e.getClass().getSimpleName() + ")"
-                                          + " convert to URI: " + 
e.getMessage());
+                    + " cannot (" + e.getClass().getSimpleName() + ")"
+                    + " convert to URI: " + e.getMessage());
         }
     }
 
     /**
      * URL/URI scheme that refers to a file
      */
-    public static final String  FILE_URL_SCHEME="file";
+    public static final String FILE_URL_SCHEME = "file";
     /**
      * Prefix used in URL(s) that reference a file resource
      */
-    public static final String  FILE_URL_PREFIX=FILE_URL_SCHEME + ":";
-    
+    public static final String FILE_URL_PREFIX = FILE_URL_SCHEME + ":";
+
     /**
      * Converts a {@link URI} that may refer to an internal resource to
      * a {@link File} representing is &quot;source&quot; container (e.g.,
      * if it is a resource in a JAR, then the result is the JAR's path)
+     *
      * @param uri The {@link URI} - ignored if {@code null}
      * @return The matching {@link File}
      * @throws MalformedURLException If source URI does not refer to a
-     * file location
+     *                               file location
      * @see URLUtils#getURLSource(URI)
      */
     public static File toFileSource(URI uri) throws MalformedURLException {
-        String  src=getURLSource(uri);
+        String src = getURLSource(uri);
         if (GenericUtils.isEmpty(src)) {
             return null;
         }
-        
+
         if (!src.startsWith(FILE_URL_PREFIX)) {
             throw new MalformedURLException("toFileSource(" + src + ") not a 
'" + FILE_URL_SCHEME + "' scheme");
         }
 
         try {
             return new File(new URI(src));
-        } catch(URISyntaxException e) {
+        } catch (URISyntaxException e) {
             throw new MalformedURLException("toFileSource(" + src + ")"
-                                          + " cannot (" + 
e.getClass().getSimpleName() + ")"
-                                          + " convert to URI: " + 
e.getMessage());
+                    + " cannot (" + e.getClass().getSimpleName() + ")"
+                    + " convert to URI: " + e.getMessage());
         }
     }
 
@@ -387,26 +393,26 @@ public class Utils {
      * Separator used in URL(s) that reference a resource inside a JAR
      * to denote the sub-path inside the JAR
      */
-    public static final char    RESOURCE_SUBPATH_SEPARATOR='!';
+    public static final char RESOURCE_SUBPATH_SEPARATOR = '!';
 
     /**
      * @param externalForm The {@link URL#toExternalForm()} string - ignored if
-     * {@code null}/empty
+     *                     {@code null}/empty
      * @return The URL(s) source path where {@link #JAR_URL_PREFIX} and
      * any sub-resource are stripped
      */
     public static final String getURLSource(String externalForm) {
-        String  url=externalForm;
+        String url = externalForm;
         if (GenericUtils.isEmpty(url)) {
             return url;
         }
 
         url = stripJarURLPrefix(externalForm);
-        if (GenericUtils.isEmpty(url)){
+        if (GenericUtils.isEmpty(url)) {
             return url;
         }
 
-        int sepPos=url.indexOf(RESOURCE_SUBPATH_SEPARATOR);
+        int sepPos = url.indexOf(RESOURCE_SUBPATH_SEPARATOR);
         if (sepPos < 0) {
             return adjustURLPathValue(url);
         } else {
@@ -430,29 +436,29 @@ public class Utils {
      * is not '/' itself
      */
     public static final String adjustURLPathValue(final String path) {
-        final int   pathLen=(path == null) ? 0 : path.length();
+        final int pathLen = (path == null) ? 0 : path.length();
         if ((pathLen <= 1) || (path.charAt(pathLen - 1) != '/')) {
             return path;
         }
 
         return path.substring(0, pathLen - 1);
     }
-    
+
     /**
      * Suffix of JAR files
      */
-    public static final String  JAR_FILE_SUFFIX=".jar";
+    public static final String JAR_FILE_SUFFIX = ".jar";
     /**
      * URL/URI scheme that refers to a JAR
      */
-    public static final String  JAR_URL_SCHEME="jar";
+    public static final String JAR_URL_SCHEME = "jar";
     /**
      * Prefix used in URL(s) that reference a resource inside a JAR
      */
-    public static final String  JAR_URL_PREFIX=JAR_URL_SCHEME + ":";
+    public static final String JAR_URL_PREFIX = JAR_URL_SCHEME + ":";
 
     public static final String stripJarURLPrefix(String externalForm) {
-        String  url=externalForm;
+        String url = externalForm;
         if (GenericUtils.isEmpty(url)) {
             return url;
         }
@@ -467,7 +473,7 @@ public class Utils {
     /**
      * Suffix of compile Java class files
      */
-    public static final String  CLASS_FILE_SUFFIX=".class";
+    public static final String CLASS_FILE_SUFFIX = ".class";
 
     /**
      * @param clazz The request {@link Class}
@@ -475,11 +481,11 @@ public class Utils {
      * - {@code null} if location could not be resolved
      */
     public static final URL getClassBytesURL(Class<?> clazz) {
-        String  className=clazz.getName();
-        int     sepPos=className.indexOf('$');
+        String className = clazz.getName();
+        int sepPos = className.indexOf('$');
         // if this is an internal class, then need to use its parent as well
         if (sepPos > 0) {
-            if ((sepPos=className.lastIndexOf('.')) > 0) {
+            if ((sepPos = className.lastIndexOf('.')) > 0) {
                 className = className.substring(sepPos + 1);
             }
         } else {
@@ -502,30 +508,30 @@ public class Utils {
             return name;
         } else {
             return new StringBuilder(name.length() + 
CLASS_FILE_SUFFIX.length())
-                            .append(name.replace('.', '/'))
-                            .append(CLASS_FILE_SUFFIX)
-                            .toString()
-                            ;
+                    .append(name.replace('.', '/'))
+                    .append(CLASS_FILE_SUFFIX)
+                    .toString()
+                    ;
         }
     }
 
-    public static final List<String>    TARGET_FOLDER_NAMES=    // NOTE: order 
is important
+    public static final List<String> TARGET_FOLDER_NAMES =    // NOTE: order 
is important
             Collections.unmodifiableList(
                     Arrays.asList("target" /* Maven */, "build" /* Gradle */));
 
     /**
      * @param anchorFile An anchor {@link File} we want to use
-     * as the starting point for the &quot;target&quot; or &quot;build&quot; 
folder
-     * lookup up the hierarchy
+     *                   as the starting point for the &quot;target&quot; or 
&quot;build&quot; folder
+     *                   lookup up the hierarchy
      * @return The &quot;target&quot; <U>folder</U> - {@code null} if not found
      */
-    public static final File detectTargetFolder (File anchorFile) {
-        for (File   file=anchorFile; file != null; file=file.getParentFile()) {
+    public static final File detectTargetFolder(File anchorFile) {
+        for (File file = anchorFile; file != null; file = 
file.getParentFile()) {
             if (!file.isDirectory()) {
                 continue;
             }
 
-            String name=file.getName();
+            String name = file.getName();
             if (TARGET_FOLDER_NAMES.contains(name)) {
                 return file;
             }
@@ -533,9 +539,9 @@ public class Utils {
 
         return null;
     }
-    
+
     public static final String resolveRelativeRemotePath(Path root, Path file) 
{
         Path relPath = root.relativize(file);
-        return relPath.toString().replace(File.separatorChar, '/'); 
+        return relPath.toString().replace(File.separatorChar, '/');
     }
 }

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-core/src/test/resources/org/apache/sshd/spring/SpringConfigTest.xml
----------------------------------------------------------------------
diff --git 
a/sshd-core/src/test/resources/org/apache/sshd/spring/SpringConfigTest.xml 
b/sshd-core/src/test/resources/org/apache/sshd/spring/SpringConfigTest.xml
index 4c6a5a2..e8a715f 100644
--- a/sshd-core/src/test/resources/org/apache/sshd/spring/SpringConfigTest.xml
+++ b/sshd-core/src/test/resources/org/apache/sshd/spring/SpringConfigTest.xml
@@ -25,16 +25,17 @@
                            http://www.springframework.org/schema/util
                            
http://www.springframework.org/schema/util/spring-util.xsd";>
 
-    <bean name="sshServer" class="org.apache.sshd.server.SshServer" 
factory-method="setUpDefaultServer" init-method="start" destroy-method="stop">
+    <bean name="sshServer" class="org.apache.sshd.server.SshServer" 
factory-method="setUpDefaultServer"
+          init-method="start" destroy-method="stop">
         <!--property name="port" value="8000" /-->
         <property name="shellFactory">
-            <util:constant 
static-field="org.apache.sshd.server.shell.InteractiveProcessShellFactory.INSTANCE"
 />
+            <util:constant 
static-field="org.apache.sshd.server.shell.InteractiveProcessShellFactory.INSTANCE"/>
         </property>
         <property name="keyPairProvider">
-            <bean 
class="org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider" />
+            <bean 
class="org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider"/>
         </property>
         <property name="passwordAuthenticator">
-            <util:constant 
static-field="org.apache.sshd.util.BogusPasswordAuthenticator.INSTANCE" />
+            <util:constant 
static-field="org.apache.sshd.util.BogusPasswordAuthenticator.INSTANCE"/>
         </property>
         <property name="publickeyAuthenticator">
             <util:constant 
static-field="org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator.INSTANCE"/>

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java
----------------------------------------------------------------------
diff --git 
a/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java 
b/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java
index 6f09d34..d23e915 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/pack/GitPackCommand.java
@@ -42,6 +42,11 @@ import org.eclipse.jgit.util.FS;
  */
 public class GitPackCommand implements Command, Runnable {
 
+    private static final int CHAR = 1;
+    private static final int DELIMITER = 2;
+    private static final int STARTQUOTE = 4;
+    private static final int ENDQUOTE = 8;
+
     private String rootDir;
     private String command;
     private InputStream in;
@@ -82,7 +87,7 @@ public class GitPackCommand implements Command, Runnable {
 
     @Override
     public void start(Environment env) throws IOException {
-        Thread  thread=new Thread(this);
+        Thread  thread = new Thread(this);
         thread.setDaemon(true);
         thread.start();
     }
@@ -144,42 +149,37 @@ public class GitPackCommand implements Command, Runnable {
 
         List<String> list = new ArrayList<String>();
 
-        int CHAR = 1;
-        int DELIMITER = 2;
-        int STARTQUOTE = 4;
-        int ENDQUOTE = 8;
-
         StringBuilder sb = new StringBuilder();
 
-        int expecting = (CHAR | DELIMITER | STARTQUOTE);
+        int expecting = CHAR | DELIMITER | STARTQUOTE;
 
         boolean isEscaped = false;
         for (int i = 0; i < value.length(); i++) {
             char c = value.charAt(i);
 
-            boolean isDelimiter = (delim.indexOf(c) >= 0);
+            boolean isDelimiter = delim.indexOf(c) >= 0;
 
-            if (!isEscaped && (c == '\\')) {
+            if (!isEscaped && c == '\\') {
                 isEscaped = true;
                 continue;
             }
 
             if (isEscaped) {
                 sb.append(c);
-            } else if (isDelimiter && ((expecting & DELIMITER) > 0)) {
+            } else if (isDelimiter && (expecting & DELIMITER) > 0) {
                 if (trim) {
                     list.add(sb.toString().trim());
                 } else {
                     list.add(sb.toString());
                 }
                 sb.delete(0, sb.length());
-                expecting = (CHAR | DELIMITER | STARTQUOTE);
-            } else if ((c == '"') && ((expecting & STARTQUOTE) > 0)) {
+                expecting = CHAR | DELIMITER | STARTQUOTE;
+            } else if ((c == '"') && (expecting & STARTQUOTE) > 0) {
                 sb.append(c);
                 expecting = CHAR | ENDQUOTE;
-            } else if ((c == '"') && ((expecting & ENDQUOTE) > 0)) {
+            } else if ((c == '"') && (expecting & ENDQUOTE) > 0) {
                 sb.append(c);
-                expecting = (CHAR | STARTQUOTE | DELIMITER);
+                expecting = CHAR | STARTQUOTE | DELIMITER;
             } else if ((expecting & CHAR) > 0) {
                 sb.append(c);
             } else {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-git/src/main/java/org/apache/sshd/git/pgm/EmbeddedCommandRunner.java
----------------------------------------------------------------------
diff --git 
a/sshd-git/src/main/java/org/apache/sshd/git/pgm/EmbeddedCommandRunner.java 
b/sshd-git/src/main/java/org/apache/sshd/git/pgm/EmbeddedCommandRunner.java
index 58d565d..7ca0d65 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/pgm/EmbeddedCommandRunner.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/pgm/EmbeddedCommandRunner.java
@@ -111,15 +111,17 @@ public class EmbeddedCommandRunner {
                 writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
                 final CommandRef[] common = CommandCatalog.common();
                 int width = 0;
-                for (final CommandRef c : common)
+                for (final CommandRef c : common) {
                     width = Math.max(width, c.getName().length());
+                }
                 width += 2;
 
                 for (final CommandRef c : common) {
                     writer.print(' ');
                     writer.print(c.getName());
-                    for (int i = c.getName().length(); i < width; i++)
+                    for (int i = c.getName().length(); i < width; i++) {
                         writer.print(' ');
+                    }
                     
writer.print(CLIText.get().resourceBundle().getString(c.getUsage()));
                     writer.println();
                 }
@@ -153,17 +155,19 @@ public class EmbeddedCommandRunner {
         
         Boolean success = (Boolean) call(cmd, "requiresRepository"); 
         if (success.booleanValue()) {
-            call(cmd, "init", new Class[] { Repository.class, String.class }, 
new Object[] { openGitDir(gitdir), gitdir });
+            call(cmd, "init", new Class[] {Repository.class, String.class}, 
new Object[] {openGitDir(gitdir), gitdir});
         } else {
-            call(cmd, "init", new Class[] { Repository.class, String.class }, 
new Object[] { null, gitdir });
+            call(cmd, "init", new Class[] {Repository.class, String.class}, 
new Object[] {null, gitdir});
         }
         try {
             cmd.execute(arguments.toArray(new String[arguments.size()]));
         } finally {
-            if (get(cmd, "outw") != null)
+            if (get(cmd, "outw") != null) {
                 ((ThrowingPrintWriter) get(cmd, "outw")).flush();
-            if (get(cmd, "errw") != null)
+            }
+            if (get(cmd, "errw") != null) {
                 ((ThrowingPrintWriter) get(cmd, "errw")).flush();
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java
----------------------------------------------------------------------
diff --git a/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java 
b/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java
index 5b296b0..b90c564 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/pgm/GitPgmCommand.java
@@ -37,6 +37,11 @@ import org.apache.sshd.server.ExitCallback;
  */
 public class GitPgmCommand implements Command, Runnable {
 
+    private static final int CHAR = 1;
+    private static final int DELIMITER = 2;
+    private static final int STARTQUOTE = 4;
+    private static final int ENDQUOTE = 8;
+
     private String rootDir;
     private String command;
     private InputStream in;
@@ -77,7 +82,7 @@ public class GitPgmCommand implements Command, Runnable {
 
     @Override
     public void start(Environment env) throws IOException {
-        Thread  thread=new Thread(this);
+        Thread  thread = new Thread(this);
         thread.setDaemon(true);
         thread.start();
     }
@@ -133,44 +138,39 @@ public class GitPgmCommand implements Command, Runnable {
             value = "";
         }
 
-        List<String> list = new ArrayList<String>();
-
-        int CHAR = 1;
-        int DELIMITER = 2;
-        int STARTQUOTE = 4;
-        int ENDQUOTE = 8;
+        List<String> list = new ArrayList<>();
 
         StringBuilder sb = new StringBuilder();
 
-        int expecting = (CHAR | DELIMITER | STARTQUOTE);
+        int expecting = CHAR | DELIMITER | STARTQUOTE;
 
         boolean isEscaped = false;
         for (int i = 0; i < value.length(); i++) {
             char c = value.charAt(i);
 
-            boolean isDelimiter = (delim.indexOf(c) >= 0);
+            boolean isDelimiter = delim.indexOf(c) >= 0;
 
-            if (!isEscaped && (c == '\\')) {
+            if (!isEscaped && c == '\\') {
                 isEscaped = true;
                 continue;
             }
 
             if (isEscaped) {
                 sb.append(c);
-            } else if (isDelimiter && ((expecting & DELIMITER) > 0)) {
+            } else if (isDelimiter && (expecting & DELIMITER) > 0) {
                 if (trim) {
                     list.add(sb.toString().trim());
                 } else {
                     list.add(sb.toString());
                 }
                 sb.delete(0, sb.length());
-                expecting = (CHAR | DELIMITER | STARTQUOTE);
-            } else if ((c == '"') && ((expecting & STARTQUOTE) > 0)) {
+                expecting = CHAR | DELIMITER | STARTQUOTE;
+            } else if ((c == '"') && (expecting & STARTQUOTE) > 0) {
                 sb.append(c);
                 expecting = CHAR | ENDQUOTE;
-            } else if ((c == '"') && ((expecting & ENDQUOTE) > 0)) {
+            } else if ((c == '"') && (expecting & ENDQUOTE) > 0) {
                 sb.append(c);
-                expecting = (CHAR | STARTQUOTE | DELIMITER);
+                expecting = CHAR | STARTQUOTE | DELIMITER;
             } else if ((expecting & CHAR) > 0) {
                 sb.append(c);
             } else {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/17f2d627/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
----------------------------------------------------------------------
diff --git 
a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
 
b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
index eeb8807..5ca73e6 100644
--- 
a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
+++ 
b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionFactory.java
@@ -27,9 +27,7 @@ import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.channel.ChannelExec;
 import org.apache.sshd.client.channel.ClientChannel;
 import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.FactoryManagerUtils;
-import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.eclipse.jgit.errors.TransportException;
 import org.eclipse.jgit.transport.CredentialItem;
@@ -46,20 +44,20 @@ import org.eclipse.jgit.util.FS;
  */
 public class GitSshdSessionFactory extends SshSessionFactory {
     /**
-     * Property used to configure the SSHD {@link FactoryManager} with
+     * Property used to configure the SSHD {@link 
org.apache.sshd.common.FactoryManager} with
      * the default timeout (millis) to connect to the remote SSH server.
      * If not specified then {@link #DEFAULT_CONNECT_TIMEOUT} is used
      */
     public static final String CONNECT_TIMEOUT_PROP = 
"git-ssh-connect-timeout";
-        public static final long DEFAULT_CONNECT_TIMEOUT = 
TimeUnit.SECONDS.toMillis(30L);
+    public static final long DEFAULT_CONNECT_TIMEOUT = 
TimeUnit.SECONDS.toMillis(30L);
 
     /**
-     * Property used to configure the SSHD {@link FactoryManager} with
+     * Property used to configure the SSHD {@link 
org.apache.sshd.common.FactoryManager} with
      * the default timeout (millis) to authenticate with the remote SSH server.
      * If not specified then {@link #DEFAULT_AUTH_TIMEOUT} is used
      */
     public static final String AUTH_TIMEOUT_PROP = "git-ssh-connect-timeout";
-        public static final long DEFAULT_AUTH_TIMEOUT = 
TimeUnit.SECONDS.toMillis(15L);
+    public static final long DEFAULT_AUTH_TIMEOUT = 
TimeUnit.SECONDS.toMillis(15L);
 
     public GitSshdSessionFactory() {
         super();
@@ -107,8 +105,7 @@ public class GitSshdSessionFactory extends 
SshSessionFactory {
             client.start();
             session = client.connect(user, host, port)
                             
.verify(FactoryManagerUtils.getLongProperty(client, CONNECT_TIMEOUT_PROP, 
DEFAULT_CONNECT_TIMEOUT))
-                            .getSession()
-                            ;
+                            .getSession();
             if (pass != null) {
                 session.addPasswordIdentity(pass);
             }

Reply via email to