Fixing NPE thrown when restarting a stopped FtpServer and improving Javadoc for this (FTPSERVER-340)
git-svn-id: https://svn.apache.org/repos/asf/mina/ftpserver/trunk@882110 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java b/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java
index caed535..680bd19 100644
--- a/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java
+++ b/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java
@@ -67,6 +67,10 @@
* @throws FtpException
*/
public void start() throws FtpException {
+ if (serverContext == null) {
+ // we have already been stopped, can not be restarted
+ throw new IllegalStateException("FtpServer has been stopped. Restart is not supported");
+ }
List<Listener> startedListeners = new ArrayList<Listener>();
@@ -99,7 +103,8 @@
}
/**
- * Stop the server. Stop the listener thread.
+ * Stop the server. Stopping the server will close completely and
+ * it not supported to restart using {@link #start()}.
*/
public void stop() {
if (serverContext == null) {