[prev in list] [next in list] [prev in thread] [next in thread]
List: mina-commits
Subject: svn commit: r709409 - in /mina/ftpserver/trunk/core/src:
From: ngn () apache ! org
Date: 2008-10-31 13:42:36
Message-ID: 20081031134236.C871F23888F4 () eris ! apache ! org
[Download RAW message or body]
Author: ngn
Date: Fri Oct 31 06:42:36 2008
New Revision: 709409
URL: http://svn.apache.org/viewvc?rev=709409&view=rev
Log:
Fixed two issues with suspend/resume.
NioListener fails to resume (FTPSERVER-209)
NioListener fails to suspend (FTPSERVER-210)
Added:
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/SuspendResumeTest.java
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java?rev=709409&r1=709408&r2=709409&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java \
(original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/impl/DefaultFtpServer.java \
Fri Oct 31 06:42:36 2008 @@ -136,6 +136,7 @@
return;
}
+ LOG.debug("Suspending server");
// stop all listeners
Map<String, Listener> listeners = serverContext.getListeners();
for (Listener listener : listeners.values()) {
@@ -143,6 +144,7 @@
}
suspended = true;
+ LOG.debug("Server suspended");
}
/**
@@ -153,12 +155,14 @@
return;
}
+ LOG.debug("Resuming server");
Map<String, Listener> listeners = serverContext.getListeners();
for (Listener listener : listeners.values()) {
listener.resume();
}
suspended = false;
+ LOG.debug("Server resumed");
}
/**
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java?rev=709409&r1=709408&r2=709409&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java \
(original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java \
Fri Oct 31 06:42:36 2008 @@ -237,7 +237,9 @@
public synchronized void resume() {
if (acceptor != null && suspended) {
try {
+ LOG.debug("Resuming listener");
acceptor.bind(address);
+ LOG.debug("Listener resumed");
} catch (IOException e) {
LOG.error("Failed to resume listener", e);
}
@@ -249,7 +251,11 @@
*/
public synchronized void suspend() {
if (acceptor != null && !suspended) {
- acceptor.unbind(address);
+ LOG.debug("Suspending listener");
+ acceptor.unbind();
+
+ suspended = true;
+ LOG.debug("Listener suspended");
}
}
Added: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/SuspendResumeTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/SuspendResumeTest.java?rev=709409&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/SuspendResumeTest.java \
(added)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/SuspendResumeTest.java \
Fri Oct 31 06:42:36 2008 @@ -0,0 +1,84 @@
+/*
+ * 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.ftpserver.clienttests;
+
+import java.io.IOException;
+
+
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
+public class SuspendResumeTest extends ClientTestTemplate {
+
+ @Override
+ protected boolean isConnectClient() {
+ return false;
+ }
+
+ public void testSuspendResumeServer() throws Exception {
+ // connect should work as expected
+ client.connect("localhost", port);
+ client.disconnect();
+
+ server.suspend();
+
+ try {
+ client.connect("localhost", port);
+ fail("Must throw IOException");
+ } catch(IOException e) {
+ // OK
+ } finally {
+ client.disconnect();
+ }
+
+ server.resume();
+
+ // connect should work again
+ client.connect("localhost", port);
+ client.disconnect();
+ }
+
+ public void testSuspendResumeListener() throws Exception {
+ // connect should work as expected
+ client.connect("localhost", port);
+ client.disconnect();
+
+ server.getListener("default").suspend();
+
+ try {
+ client.connect("localhost", port);
+ fail("Must throw IOException");
+ } catch(IOException e) {
+ // OK
+ } finally {
+ client.disconnect();
+ }
+
+ server.getListener("default").resume();
+
+ // connect should work again
+ client.connect("localhost", port);
+ client.disconnect();
+ }
+
+}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic