Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C6DDD10E05 for ; Thu, 20 Feb 2014 10:53:00 +0000 (UTC) Received: (qmail 18939 invoked by uid 500); 20 Feb 2014 10:52:59 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 18883 invoked by uid 500); 20 Feb 2014 10:52:58 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 18870 invoked by uid 99); 20 Feb 2014 10:52:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Feb 2014 10:52:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Thu, 20 Feb 2014 10:52:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B8C9523888D7 for ; Thu, 20 Feb 2014 10:52:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1570138 - in /httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn: LoggingInputStream.java LoggingOutputStream.java Wire.java Date: Thu, 20 Feb 2014 10:52:30 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140220105230.B8C9523888D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Thu Feb 20 10:52:30 2014 New Revision: 1570138 URL: http://svn.apache.org/r1570138 Log: Wire log to include I/O errors and end of stream Modified: httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java Modified: httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java?rev=1570138&r1=1570137&r2=1570138&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java (original) +++ httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java Thu Feb 20 10:52:30 2014 @@ -51,48 +51,79 @@ class LoggingInputStream extends InputSt @Override public int read() throws IOException { - final int b = in.read(); - if (b != -1) { - wire.input(b); + try { + final int b = in.read(); + if (b == -1) { + wire.input("end of stream"); + } else { + wire.input(b); + } + return b; + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; } - return b; } @Override public int read(final byte[] b) throws IOException { - final int bytesRead = in.read(b); - if (bytesRead != -1) { - wire.input(b, 0, bytesRead); + try { + final int bytesRead = in.read(b); + if (bytesRead == -1) { + wire.input("end of stream"); + } else if (bytesRead > 0) { + wire.input(b, 0, bytesRead); + } + return bytesRead; + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; } - return bytesRead; } @Override public int read(final byte[] b, final int off, final int len) throws IOException { - final int bytesRead = in.read(b, off, len); - if (bytesRead != -1) { - wire.input(b, off, bytesRead); + try { + final int bytesRead = in.read(b, off, len); + if (bytesRead == -1) { + wire.input("end of stream"); + } else if (bytesRead > 0) { + wire.input(b, off, bytesRead); + } + return bytesRead; + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; } - return bytesRead; } @Override public long skip(final long n) throws IOException { - return super.skip(n); + try { + return super.skip(n); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } @Override public int available() throws IOException { - return in.available(); + try { + return in.available(); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } @Override - public synchronized void mark(final int readlimit) { + public void mark(final int readlimit) { super.mark(readlimit); } @Override - public synchronized void reset() throws IOException { + public void reset() throws IOException { super.reset(); } @@ -103,7 +134,12 @@ class LoggingInputStream extends InputSt @Override public void close() throws IOException { - in.close(); + try { + in.close(); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } } Modified: httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java?rev=1570138&r1=1570137&r2=1570138&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java (original) +++ httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java Thu Feb 20 10:52:30 2014 @@ -51,29 +51,54 @@ class LoggingOutputStream extends Output @Override public void write(final int b) throws IOException { - wire.output(b); + try { + wire.output(b); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void write(final byte[] b) throws IOException { - wire.output(b); - out.write(b); + try { + wire.output(b); + out.write(b); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void write(final byte[] b, final int off, final int len) throws IOException { - wire.output(b, off, len); - out.write(b, off, len); + try { + wire.output(b, off, len); + out.write(b, off, len); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void flush() throws IOException { - out.flush(); + try { + out.flush(); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void close() throws IOException { - out.close(); + try { + out.close(); + } catch (IOException ex) { + wire.input("I/O error: " + ex.getMessage()); + throw ex; + } } } Modified: httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java?rev=1570138&r1=1570137&r2=1570138&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java (original) +++ httpcomponents/httpclient/branches/4.3.x/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java Thu Feb 20 10:52:30 2014 @@ -138,20 +138,12 @@ public class Wire { input(new byte[] {(byte) b}); } - /** - * @deprecated (4.1) do not use - */ - @Deprecated public void output(final String s) throws IOException { Args.notNull(s, "Output"); output(s.getBytes()); } - /** - * @deprecated (4.1) do not use - */ - @Deprecated public void input(final String s) throws IOException { Args.notNull(s, "Input");