Author: ngn
Date: Tue Jan 13 13:05:31 2009
New Revision: 734241

URL: http://svn.apache.org/viewvc?rev=734241&view=rev
Log:
We now close the stream provided by the file system within the scope for 
sending an error to the client. So, if the file system throws an exception on 
closing the stream, we will now send an error to the client (FTPSERVER-119)

Modified:
    
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

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=734241&r1=734240&r2=734241&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
 Tue Jan 13 13:05:31 2009
@@ -162,15 +162,18 @@
                 // transfer data
                 long transSz = 
dataConnection.transferFromClient(session.getFtpletSession(), os);
 
-                // log message
-                String userName = session.getUser().getName();
-
-                LOG.info("File upload : " + userName + " - " + fileName);
+                LOG.info("File uploaded {}", fileName);
 
                 // notify the statistics component
                 ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
                         .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;
@@ -189,6 +192,7 @@
                                         
FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
                                         "APPE", fileName));
             } finally {
+                // make sure we really close the output stream
                 IoUtils.close(os);
             }
 

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=734241&r1=734240&r2=734241&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
 Tue Jan 13 13:05:31 2009
@@ -166,9 +166,7 @@
                 // transfer data
                 long transSz = 
dataConnection.transferToClient(session.getFtpletSession(), is);
 
-                // log message
-                String userName = session.getUser().getName();
-                LOG.info("File download : " + userName + " - " + fileName);
+                LOG.info("File downloaded {}", fileName);
 
                 // notify the statistics component
                 ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
@@ -176,6 +174,12 @@
                 if (ftpStat != null) {
                     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;
@@ -194,6 +198,7 @@
                                         
FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
                                         "RETR", fileName));
             } finally {
+                // make sure we really close the input stream
                 IoUtils.close(is);
             }
 

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=734241&r1=734240&r2=734241&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
 Tue Jan 13 13:05:31 2009
@@ -146,14 +146,18 @@
                 outStream = file.createOutputStream(skipLen);
                 long transSz = 
dataConnection.transferFromClient(session.getFtpletSession(), outStream);
 
-                // log message
-                String userName = session.getUser().getName();
-                LOG.info("File upload : " + userName + " - " + fileName);
+                LOG.info("File uploaded {}", fileName);
 
                 // notify the statistics component
                 ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
                         .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;
@@ -172,6 +176,7 @@
                                         
FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
                                         "STOR", fileName));
             } finally {
+                // make sure we really close the output stream
                 IoUtils.close(outStream);
             }
 

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=734241&r1=734240&r2=734241&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
 Tue Jan 13 13:05:31 2009
@@ -153,9 +153,7 @@
                 // transfer data
                 long transSz = 
dataConnection.transferFromClient(session.getFtpletSession(), os);
 
-                // log message
-                String userName = session.getUser().getName();
-                LOG.info("File upload : " + userName + " - " + fileName);
+                LOG.info("File uploaded {}", fileName);
 
                 // notify the statistics component
                 ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
@@ -163,6 +161,12 @@
                 if (ftpStat != null) {
                     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;
@@ -181,6 +185,7 @@
                                         
FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
                                         "STOU", fileName));
             } finally {
+                // make sure we really close the output stream
                 IoUtils.close(os);
             }
 


Reply via email to