Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 67497 invoked from network); 14 Feb 2009 02:32:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Feb 2009 02:32:43 -0000 Received: (qmail 56508 invoked by uid 500); 14 Feb 2009 02:32:42 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 56429 invoked by uid 500); 14 Feb 2009 02:32:42 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 56420 invoked by uid 99); 14 Feb 2009 02:32:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2009 18:32:42 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2009 02:32:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 070EB238887D; Sat, 14 Feb 2009 02:32:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r744371 - in /commons/proper/io/trunk/src/java/org/apache/commons/io: input/ProxyInputStream.java input/ProxyReader.java output/ProxyOutputStream.java output/ProxyWriter.java Date: Sat, 14 Feb 2009 02:32:20 -0000 To: commits@commons.apache.org From: niallp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090214023221.070EB238887D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: niallp Date: Sat Feb 14 02:32:19 2009 New Revision: 744371 URL: http://svn.apache.org/viewvc?rev=744371&view=rev Log: IO-195 Provide exception handling methods in the Proxy streams/readers Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java?rev=744371&r1=744370&r2=744371&view=diff ============================================================================== --- commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java (original) +++ commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java Sat Feb 14 02:32:19 2009 @@ -51,7 +51,12 @@ */ @Override public int read() throws IOException { - return in.read(); + try { + return in.read(); + } catch (IOException e) { + handleIOException(e); + return -1; + } } /** @@ -62,7 +67,12 @@ */ @Override public int read(byte[] bts) throws IOException { - return in.read(bts); + try { + return in.read(bts); + } catch (IOException e) { + handleIOException(e); + return -1; + } } /** @@ -75,7 +85,12 @@ */ @Override public int read(byte[] bts, int st, int end) throws IOException { - return in.read(bts, st, end); + try { + return in.read(bts, st, end); + } catch (IOException e) { + handleIOException(e); + return -1; + } } /** @@ -86,7 +101,12 @@ */ @Override public long skip(long ln) throws IOException { - return in.skip(ln); + try { + return in.skip(ln); + } catch (IOException e) { + handleIOException(e); + return 0; + } } /** @@ -96,7 +116,12 @@ */ @Override public int available() throws IOException { - return in.available(); + try { + return super.available(); + } catch (IOException e) { + handleIOException(e); + return 0; + } } /** @@ -105,7 +130,11 @@ */ @Override public void close() throws IOException { - in.close(); + try { + in.close(); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -123,7 +152,11 @@ */ @Override public synchronized void reset() throws IOException { - in.reset(); + try { + in.reset(); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -135,4 +168,18 @@ return in.markSupported(); } + + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since Commons IO 2.0 + */ + protected void handleIOException(IOException e) throws IOException { + throw e; + } + } Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java?rev=744371&r1=744370&r2=744371&view=diff ============================================================================== --- commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java (original) +++ commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java Sat Feb 14 02:32:19 2009 @@ -52,7 +52,12 @@ */ @Override public int read() throws IOException { - return in.read(); + try { + return in.read(); + } catch (IOException e) { + handleIOException(e); + return -1; + } } /** @@ -63,7 +68,12 @@ */ @Override public int read(char[] chr) throws IOException { - return in.read(chr); + try { + return in.read(chr); + } catch (IOException e) { + handleIOException(e); + return -1; + } } /** @@ -76,7 +86,12 @@ */ @Override public int read(char[] chr, int st, int end) throws IOException { - return in.read(chr, st, end); + try { + return in.read(chr, st, end); + } catch (IOException e) { + handleIOException(e); + return -1; + } } /** @@ -88,7 +103,12 @@ */ @Override public int read(CharBuffer target) throws IOException { - return in.read(target); + try { + return in.read(target); + } catch (IOException e) { + handleIOException(e); + return -1; + } } /** @@ -99,7 +119,12 @@ */ @Override public long skip(long ln) throws IOException { - return in.skip(ln); + try { + return in.skip(ln); + } catch (IOException e) { + handleIOException(e); + return 0; + } } /** @@ -109,7 +134,12 @@ */ @Override public boolean ready() throws IOException { - return in.ready(); + try { + return in.ready(); + } catch (IOException e) { + handleIOException(e); + return false; + } } /** @@ -118,7 +148,11 @@ */ @Override public void close() throws IOException { - in.close(); + try { + in.close(); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -128,7 +162,11 @@ */ @Override public synchronized void mark(int idx) throws IOException { - in.mark(idx); + try { + in.mark(idx); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -137,7 +175,11 @@ */ @Override public synchronized void reset() throws IOException { - in.reset(); + try { + in.reset(); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -149,4 +191,17 @@ return in.markSupported(); } + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since Commons IO 2.0 + */ + protected void handleIOException(IOException e) throws IOException { + throw e; + } + } Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java?rev=744371&r1=744370&r2=744371&view=diff ============================================================================== --- commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java (original) +++ commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java Sat Feb 14 02:32:19 2009 @@ -48,7 +48,11 @@ */ @Override public void write(int idx) throws IOException { - out.write(idx); + try { + out.write(idx); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -58,7 +62,11 @@ */ @Override public void write(byte[] bts) throws IOException { - out.write(bts); + try { + out.write(bts); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -70,7 +78,11 @@ */ @Override public void write(byte[] bts, int st, int end) throws IOException { - out.write(bts, st, end); + try { + out.write(bts, st, end); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -79,7 +91,11 @@ */ @Override public void flush() throws IOException { - out.flush(); + try { + out.flush(); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -88,7 +104,24 @@ */ @Override public void close() throws IOException { - out.close(); + try { + out.close(); + } catch (IOException e) { + handleIOException(e); + } + } + + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since Commons IO 2.0 + */ + protected void handleIOException(IOException e) throws IOException { + throw e; } } Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java?rev=744371&r1=744370&r2=744371&view=diff ============================================================================== --- commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java (original) +++ commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java Sat Feb 14 02:32:19 2009 @@ -52,7 +52,11 @@ */ @Override public Writer append(char c) throws IOException { - out.append(c); + try { + out.append(c); + } catch (IOException e) { + handleIOException(e); + } return this; } @@ -67,7 +71,11 @@ */ @Override public Writer append(CharSequence csq, int start, int end) throws IOException { - out.append(csq, start, end); + try { + out.append(csq, start, end); + } catch (IOException e) { + handleIOException(e); + } return this; } @@ -80,7 +88,11 @@ */ @Override public Writer append(CharSequence csq) throws IOException { - out.append(csq); + try { + out.append(csq); + } catch (IOException e) { + handleIOException(e); + } return this; } @@ -91,7 +103,11 @@ */ @Override public void write(int idx) throws IOException { - out.write(idx); + try { + out.write(idx); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -101,7 +117,11 @@ */ @Override public void write(char[] chr) throws IOException { - out.write(chr); + try { + out.write(chr); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -113,7 +133,11 @@ */ @Override public void write(char[] chr, int st, int end) throws IOException { - out.write(chr, st, end); + try { + out.write(chr, st, end); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -123,7 +147,11 @@ */ @Override public void write(String str) throws IOException { - out.write(str); + try { + out.write(str); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -135,7 +163,11 @@ */ @Override public void write(String str, int st, int end) throws IOException { - out.write(str, st, end); + try { + out.write(str, st, end); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -144,7 +176,11 @@ */ @Override public void flush() throws IOException { - out.flush(); + try { + out.flush(); + } catch (IOException e) { + handleIOException(e); + } } /** @@ -153,7 +189,24 @@ */ @Override public void close() throws IOException { - out.close(); + try { + out.close(); + } catch (IOException e) { + handleIOException(e); + } + } + + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since Commons IO 2.0 + */ + protected void handleIOException(IOException e) throws IOException { + throw e; } }