[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-commit] r168 - in jetty/trunk: . jetty-util/src/main/java/org/eclipse/jetty/util

Author: jmcconnell
Date: 2009-04-21 14:02:37 -0400 (Tue, 21 Apr 2009)
New Revision: 168

Modified:
   jetty/trunk/VERSION.txt
   jetty/trunk/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java
Log:
[BUG-271536] add support for closing readers and writers for IO

Modified: jetty/trunk/VERSION.txt
===================================================================
--- jetty/trunk/VERSION.txt	2009-04-21 08:03:02 UTC (rev 167)
+++ jetty/trunk/VERSION.txt	2009-04-21 18:02:37 UTC (rev 168)
@@ -6,6 +6,7 @@
  + Reworked authentication for deferred authentication
  + JETTY-983 DefaultServlet generates accept-ranges for cached/gzip content
  + 273011 JETTY-980 JETTY-992 Security / Directory Listing XSS present
+ + 271536 Add supprot to IO for quietly closing Readers / Writers
 
 jetty-7.0.0.M0
  + JETTY-496 Support inetd/xinetd through use of System.inheritedChannel()

Modified: jetty/trunk/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java
===================================================================
--- jetty/trunk/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java	2009-04-21 08:03:02 UTC (rev 167)
+++ jetty/trunk/jetty-util/src/main/java/org/eclipse/jetty/util/IO.java	2009-04-21 18:02:37 UTC (rev 168)
@@ -12,6 +12,7 @@
 // ========================================================================
 
 package org.eclipse.jetty.util;
+import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -357,6 +358,40 @@
         }
     }
 
+    /**
+     * closes a reader, and logs exceptions
+     * 
+     * @param reader the reader to close
+     */
+    public static void close(Reader reader)
+    {
+        try
+        {
+            if (reader != null)
+                reader.close();
+        } catch (IOException e)
+        {
+            Log.ignore(e);
+        }
+    }
+
+    /**
+     * closes a writer, and logs exceptions
+     * 
+     * @param writer the writer to close
+     */
+    public static void close(Writer writer)
+    {
+        try
+        {
+            if (writer != null)
+                writer.close();
+        } catch (IOException e)
+        {
+            Log.ignore(e);
+        }
+    }
+    
     /* ------------------------------------------------------------ */
     public static byte[] readBytes(InputStream in)
         throws IOException