This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch 1.2.X
in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git


The following commit(s) were added to refs/heads/1.2.X by this push:
     new c238aa46 Code formatting
c238aa46 is described below

commit c238aa46c508b258d4a03e956c8ddc5fe185fa01
Author: emmanuel lecharny <elecha...@apache.org>
AuthorDate: Wed Jul 12 09:43:07 2023 +0200

    Code formatting
---
 .../apache/ftpserver/listener/nio/NioListener.java | 240 +++++++++++----------
 1 file changed, 122 insertions(+), 118 deletions(-)

diff --git 
a/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java 
b/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
index cfa5d45e..460970d7 100644
--- a/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
+++ b/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
@@ -79,178 +79,182 @@ public class NioListener extends AbstractListener {
      */
     @Deprecated
     public NioListener(String serverAddress, int port, boolean implicitSsl, 
SslConfiguration sslConfiguration, DataConnectionConfiguration 
dataConnectionConfig, int idleTimeout, List<InetAddress> blockedAddresses, 
List<Subnet> blockedSubnets) {
-    super(serverAddress, port, implicitSsl, sslConfiguration, 
dataConnectionConfig, idleTimeout, blockedAddresses, blockedSubnets);
+        super(serverAddress, port, implicitSsl, sslConfiguration, 
dataConnectionConfig, idleTimeout, blockedAddresses, blockedSubnets);
     }
 
     /**
      * Constructor for internal use, do not use directly. Instead use {@link 
ListenerFactory}
      */
     public NioListener(String serverAddress, int port, boolean implicitSsl, 
SslConfiguration sslConfiguration, DataConnectionConfiguration 
dataConnectionConfig, int idleTimeout, SessionFilter sessionFilter) {
-    super(serverAddress, port, implicitSsl, sslConfiguration, 
dataConnectionConfig, idleTimeout, sessionFilter);
+        super(serverAddress, port, implicitSsl, sslConfiguration, 
dataConnectionConfig, idleTimeout, sessionFilter);
     }
 
     /**
      * @see Listener#start(FtpServerContext)
      */
     public synchronized void start(FtpServerContext context) {
-    if (!isStopped()) {
-        // listener already started, don't allow
-        throw new IllegalStateException("Listener already started");
-    }
-
-    try {
-
-        this.context = context;
-
-        acceptor = new 
NioSocketAcceptor(Runtime.getRuntime().availableProcessors());
-
-        if (getServerAddress() != null) {
-        address = new InetSocketAddress(getServerAddress(), getPort());
-        } else {
-        address = new InetSocketAddress(getPort());
+        if (!isStopped()) {
+            // listener already started, don't allow
+            throw new IllegalStateException("Listener already started");
         }
-
-        acceptor.setReuseAddress(true);
-        acceptor.getSessionConfig().setReadBufferSize(2048);
-        acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 
getIdleTimeout());
-        // Decrease the default receiver buffer size
-        acceptor.getSessionConfig().setReceiveBufferSize(512);
-
-        MdcInjectionFilter mdcFilter = new MdcInjectionFilter();
-
-        acceptor.getFilterChain().addLast("mdcFilter", mdcFilter);
-
-        SessionFilter sessionFilter = getSessionFilter();
-        if (sessionFilter != null) {
-        // add and IP filter to the filter chain.
-        acceptor.getFilterChain().addLast("sessionFilter", new 
MinaSessionFilter(sessionFilter));
-        }
-
-        acceptor.getFilterChain().addLast("threadPool", new 
ExecutorFilter(context.getThreadPoolExecutor()));
-        acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new 
FtpServerProtocolCodecFactory()));
-        acceptor.getFilterChain().addLast("mdcFilter2", mdcFilter);
-        acceptor.getFilterChain().addLast("logger", new FtpLoggingFilter());
-
-        if (isImplicitSsl()) {
-        SslConfiguration ssl_conf = getSslConfiguration();
-        SslFilter ssl_filter;
+    
         try {
-            ssl_filter = new SslFilter(ssl_conf.getSSLContext());
-        } catch (GeneralSecurityException e) {
-            throw new FtpServerConfigurationException("SSL could not be 
initialized, check configuration");
-        }
-
-        if (ssl_conf.getClientAuth() == ClientAuth.NEED) {
-            ssl_filter.setNeedClientAuth(true);
-        } else if (ssl_conf.getClientAuth() == ClientAuth.WANT) {
-            ssl_filter.setWantClientAuth(true);
-        }
-
-        if (ssl_conf.getEnabledProtocols() != null) {
-            ssl_filter.setEnabledProtocols(ssl_conf.getEnabledProtocols());
+    
+            this.context = context;
+    
+            acceptor = new 
NioSocketAcceptor(Runtime.getRuntime().availableProcessors());
+    
+            if (getServerAddress() != null) {
+                address = new InetSocketAddress(getServerAddress(), getPort());
+            } else {
+                address = new InetSocketAddress(getPort());
+            }
+    
+            acceptor.setReuseAddress(true);
+            acceptor.getSessionConfig().setReadBufferSize(2048);
+            acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 
getIdleTimeout());
+            // Decrease the default receiver buffer size
+            acceptor.getSessionConfig().setReceiveBufferSize(512);
+    
+            MdcInjectionFilter mdcFilter = new MdcInjectionFilter();
+    
+            acceptor.getFilterChain().addLast("mdcFilter", mdcFilter);
+    
+            SessionFilter sessionFilter = getSessionFilter();
+            
+            if (sessionFilter != null) {
+                // add and IP filter to the filter chain.
+                acceptor.getFilterChain().addLast("sessionFilter", new 
MinaSessionFilter(sessionFilter));
+            }
+    
+            acceptor.getFilterChain().addLast("threadPool", new 
ExecutorFilter(context.getThreadPoolExecutor()));
+            acceptor.getFilterChain().addLast("codec", new 
ProtocolCodecFilter(new FtpServerProtocolCodecFactory()));
+            acceptor.getFilterChain().addLast("mdcFilter2", mdcFilter);
+            acceptor.getFilterChain().addLast("logger", new 
FtpLoggingFilter());
+    
+            if (isImplicitSsl()) {
+                SslConfiguration ssl_conf = getSslConfiguration();
+                SslFilter ssl_filter;
+                
+                try {
+                    ssl_filter = new SslFilter(ssl_conf.getSSLContext());
+                } catch (GeneralSecurityException e) {
+                    throw new FtpServerConfigurationException("SSL could not 
be initialized, check configuration");
+                }
+        
+                if (ssl_conf.getClientAuth() == ClientAuth.NEED) {
+                    ssl_filter.setNeedClientAuth(true);
+                } else if (ssl_conf.getClientAuth() == ClientAuth.WANT) {
+                    ssl_filter.setWantClientAuth(true);
+                }
+        
+                if (ssl_conf.getEnabledProtocols() != null) {
+                    
ssl_filter.setEnabledProtocols(ssl_conf.getEnabledProtocols());
+                }
+        
+                if (ssl_conf.getEnabledCipherSuites() != null) {
+                    
ssl_filter.setEnabledCipherSuites(ssl_conf.getEnabledCipherSuites());
+                }
+        
+                acceptor.getFilterChain().addFirst("sslFilter", ssl_filter);
+            }
+    
+            handler.init(context, this);
+            acceptor.setHandler(new FtpHandlerAdapter(context, handler));
+    
+            try {
+                acceptor.bind(address);
+            } catch (IOException e) {
+                throw new FtpServerConfigurationException("Failed to bind to 
address " + address + ", check configuration", e);
+            }
+    
+            updatePort();
+    
+        } catch (RuntimeException e) {
+            // clean up if we fail to start
+            stop();
+    
+            throw e;
         }
-
-        if (ssl_conf.getEnabledCipherSuites() != null) {
-            
ssl_filter.setEnabledCipherSuites(ssl_conf.getEnabledCipherSuites());
-        }
-
-        acceptor.getFilterChain().addFirst("sslFilter", ssl_filter);
-        }
-
-        handler.init(context, this);
-        acceptor.setHandler(new FtpHandlerAdapter(context, handler));
-
-        try {
-        acceptor.bind(address);
-        } catch (IOException e) {
-        throw new FtpServerConfigurationException("Failed to bind to address " 
+ address + ", check configuration", e);
-        }
-
-        updatePort();
-
-    } catch (RuntimeException e) {
-        // clean up if we fail to start
-        stop();
-
-        throw e;
-    }
     }
 
     private void updatePort() {
-    // update the port to the real port bound by the listener
-    setPort(acceptor.getLocalAddress().getPort());
+        // update the port to the real port bound by the listener
+        setPort(acceptor.getLocalAddress().getPort());
     }
 
     /**
      * @see Listener#stop()
      */
     public synchronized void stop() {
-    // close server socket
-    if (acceptor != null) {
-        acceptor.unbind();
-        acceptor.dispose();
-        acceptor = null;
-    }
-    context = null;
+        // close server socket
+        if (acceptor != null) {
+            acceptor.unbind();
+            acceptor.dispose();
+            acceptor = null;
+        }
+        
+        context = null;
     }
 
     /**
      * @see Listener#isStopped()
      */
     public boolean isStopped() {
-    return acceptor == null;
+        return acceptor == null;
     }
 
     /**
      * @see Listener#isSuspended()
      */
     public boolean isSuspended() {
-    return suspended;
-
+        return suspended;
     }
 
     /**
      * @see Listener#resume()
      */
     public synchronized void resume() {
-    if (acceptor != null && suspended) {
-        try {
-        LOG.debug("Resuming listener");
-        acceptor.bind(address);
-        LOG.debug("Listener resumed");
-
-        updatePort();
-
-        suspended = false;
-        } catch (IOException e) {
-        LOG.error("Failed to resume listener", e);
+        if (acceptor != null && suspended) {
+            try {
+                LOG.debug("Resuming listener");
+                acceptor.bind(address);
+                LOG.debug("Listener resumed");
+        
+                updatePort();
+        
+                suspended = false;
+            } catch (IOException e) {
+                LOG.error("Failed to resume listener", e);
+            }
         }
     }
-    }
 
     /**
      * @see Listener#suspend()
      */
     public synchronized void suspend() {
-    if (acceptor != null && !suspended) {
-        LOG.debug("Suspending listener");
-        acceptor.unbind();
-
-        suspended = true;
-        LOG.debug("Listener suspended");
-    }
+        if (acceptor != null && !suspended) {
+            LOG.debug("Suspending listener");
+            acceptor.unbind();
+    
+            suspended = true;
+            LOG.debug("Listener suspended");
+        }
     }
 
     /**
      * @see Listener#getActiveSessions()
      */
     public synchronized Set<FtpIoSession> getActiveSessions() {
-    Map<Long, IoSession> sessions = acceptor.getManagedSessions();
-
-    Set<FtpIoSession> ftpSessions = new HashSet<FtpIoSession>();
-    for (IoSession session : sessions.values()) {
-        ftpSessions.add(new FtpIoSession(session, context));
-    }
-    return ftpSessions;
+        Map<Long, IoSession> sessions = acceptor.getManagedSessions();
+    
+        Set<FtpIoSession> ftpSessions = new HashSet<FtpIoSession>();
+        
+        for (IoSession session : sessions.values()) {
+            ftpSessions.add(new FtpIoSession(session, context));
+        }
+        
+        return ftpSessions;
     }
 }

Reply via email to