commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1362321 - in /commons/proper/net/trunk/src/main/java/org/apache/commons/net: ftp/FTPFile.java nntp/NNTPClient.java
Date Tue, 17 Jul 2012 00:08:19 GMT
Author: sebb
Date: Tue Jul 17 00:08:19 2012
New Revision: 1362321

URL: http://svn.apache.org/viewvc?rev=1362321&view=rev
Log:
Ensure resources are closed

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTPClient.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java?rev=1362321&r1=1362320&r2=1362321&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java Tue Jul
17 00:08:19 2012
@@ -405,6 +405,7 @@ public class FTPFile implements Serializ
         }
         sb.append(' ');
         sb.append(getName());
+        fmt.close();
         return sb.toString();
     }
 

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTPClient.java?rev=1362321&r1=1362320&r2=1362321&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/NNTPClient.java Tue
Jul 17 00:08:19 2012
@@ -253,16 +253,18 @@ public class NNTPClient extends NNTP
         Vector<NewsgroupInfo> list = new Vector<NewsgroupInfo>(2048);
 
         String line;
-        while ((line = reader.readLine()) != null)
-        {
-            NewsgroupInfo tmp = __parseNewsgroupListEntry(line);
-            if (tmp != null) {
-                list.addElement(tmp);
-            } else {
-                throw new MalformedServerReplyException(line);
+        try {
+            while ((line = reader.readLine()) != null) {
+                NewsgroupInfo tmp = __parseNewsgroupListEntry(line);
+                if (tmp != null) {
+                    list.addElement(tmp);
+                } else {
+                    throw new MalformedServerReplyException(line);
+                }
             }
+        } finally {
+            reader.close();
         }
-
         int size;
         if ((size = list.size()) < 1) {
             return new NewsgroupInfo[0];
@@ -1215,8 +1217,12 @@ public class NNTPClient extends NNTP
         BufferedReader reader = new DotTerminatedMessageReader(_reader_);
 
         String line;
-        while ((line = reader.readLine()) != null) {
-            list.addElement(line);
+        try {
+            while ((line = reader.readLine()) != null) {
+                list.addElement(line);
+            }
+        } finally {
+            reader.close();
         }
 
         int size = list.size();



Mime
View raw message