Author: ngn
Date: Sun Mar 8 09:33:17 2009
New Revision: 751390
URL: http://svn.apache.org/viewvc?rev=751390&view=rev
Log:
Closing streams on up-/downloads so that a failure to do so will keep
statistics correct (FTPSERVER-269)
Modified:
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/InetAddressBlacklistTest.java
Modified:
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
(original)
+++
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
Sun Mar 8 09:33:17 2009
@@ -162,6 +162,12 @@
// transfer data
long transSz =
dataConnection.transferFromClient(session.getFtpletSession(), os);
+ // attempt to close the output stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(os != null) {
+ os.close();
+ }
+
LOG.info("File uploaded {}", fileName);
// notify the statistics component
@@ -169,11 +175,6 @@
.getFtpStatistics();
ftpStat.setUpload(session, file, transSz);
- // attempt to close the output stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(os != null) {
- os.close();
- }
} catch (SocketException e) {
LOG.debug("SocketException during file upload", e);
failure = true;
Modified:
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
(original)
+++
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
Sun Mar 8 09:33:17 2009
@@ -165,6 +165,11 @@
// transfer data
long transSz =
dataConnection.transferToClient(session.getFtpletSession(), is);
+ // attempt to close the input stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(is != null) {
+ is.close();
+ }
LOG.info("File downloaded {}", fileName);
@@ -175,11 +180,6 @@
ftpStat.setDownload(session, file, transSz);
}
- // attempt to close the input stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(is != null) {
- is.close();
- }
} catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
Modified:
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
(original)
+++
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
Sun Mar 8 09:33:17 2009
@@ -146,6 +146,12 @@
outStream = file.createOutputStream(skipLen);
long transSz =
dataConnection.transferFromClient(session.getFtpletSession(), outStream);
+ // attempt to close the output stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(outStream != null) {
+ outStream.close();
+ }
+
LOG.info("File uploaded {}", fileName);
// notify the statistics component
@@ -153,11 +159,6 @@
.getFtpStatistics();
ftpStat.setUpload(session, file, transSz);
- // attempt to close the output stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(outStream != null) {
- outStream.close();
- }
} catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
Modified:
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
(original)
+++
mina/ftpserver/branches/1.0.x/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
Sun Mar 8 09:33:17 2009
@@ -153,6 +153,12 @@
// transfer data
long transSz =
dataConnection.transferFromClient(session.getFtpletSession(), os);
+ // attempt to close the output stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(os != null) {
+ os.close();
+ }
+
LOG.info("File uploaded {}", fileName);
// notify the statistics component
@@ -162,11 +168,6 @@
ftpStat.setUpload(session, file, transSz);
}
- // attempt to close the output stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(os != null) {
- os.close();
- }
} catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
(original)
+++
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/APPE.java
Sun Mar 8 09:33:17 2009
@@ -162,6 +162,12 @@
// transfer data
long transSz =
dataConnection.transferFromClient(session.getFtpletSession(), os);
+ // attempt to close the output stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(os != null) {
+ os.close();
+ }
+
LOG.info("File uploaded {}", fileName);
// notify the statistics component
@@ -169,11 +175,6 @@
.getFtpStatistics();
ftpStat.setUpload(session, file, transSz);
- // attempt to close the output stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(os != null) {
- os.close();
- }
} catch (SocketException e) {
LOG.debug("SocketException during file upload", e);
failure = true;
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
(original)
+++
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/RETR.java
Sun Mar 8 09:33:17 2009
@@ -165,6 +165,11 @@
// transfer data
long transSz =
dataConnection.transferToClient(session.getFtpletSession(), is);
+ // attempt to close the input stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(is != null) {
+ is.close();
+ }
LOG.info("File downloaded {}", fileName);
@@ -175,11 +180,6 @@
ftpStat.setDownload(session, file, transSz);
}
- // attempt to close the input stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(is != null) {
- is.close();
- }
} catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
(original)
+++
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOR.java
Sun Mar 8 09:33:17 2009
@@ -146,6 +146,12 @@
outStream = file.createOutputStream(skipLen);
long transSz =
dataConnection.transferFromClient(session.getFtpletSession(), outStream);
+ // attempt to close the output stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(outStream != null) {
+ outStream.close();
+ }
+
LOG.info("File uploaded {}", fileName);
// notify the statistics component
@@ -153,11 +159,6 @@
.getFtpStatistics();
ftpStat.setUpload(session, file, transSz);
- // attempt to close the output stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(outStream != null) {
- outStream.close();
- }
} catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
(original)
+++
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/impl/STOU.java
Sun Mar 8 09:33:17 2009
@@ -153,6 +153,12 @@
// transfer data
long transSz =
dataConnection.transferFromClient(session.getFtpletSession(), os);
+ // attempt to close the output stream so that errors in
+ // closing it will return an error to the client
(FTPSERVER-119)
+ if(os != null) {
+ os.close();
+ }
+
LOG.info("File uploaded {}", fileName);
// notify the statistics component
@@ -162,11 +168,6 @@
ftpStat.setUpload(session, file, transSz);
}
- // attempt to close the output stream so that errors in
- // closing it will return an error to the client
(FTPSERVER-119)
- if(os != null) {
- os.close();
- }
} catch (SocketException ex) {
LOG.debug("Socket exception during data transfer", ex);
failure = true;
Modified:
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/InetAddressBlacklistTest.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/InetAddressBlacklistTest.java?rev=751390&r1=751389&r2=751390&view=diff
==============================================================================
---
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/InetAddressBlacklistTest.java
(original)
+++
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/clienttests/InetAddressBlacklistTest.java
Sun Mar 8 09:33:17 2009
@@ -25,7 +25,6 @@
import org.apache.commons.net.ftp.FTPConnectionClosedException;
import org.apache.ftpserver.FtpServerFactory;
-import org.apache.ftpserver.impl.DefaultFtpServer;
import org.apache.ftpserver.listener.ListenerFactory;
/**