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 AD04B1982E for ; Thu, 28 Apr 2016 09:39:09 +0000 (UTC) Received: (qmail 59415 invoked by uid 500); 28 Apr 2016 09:39:09 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 59371 invoked by uid 500); 28 Apr 2016 09:39:09 -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 59362 invoked by uid 99); 28 Apr 2016 09:39:09 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Apr 2016 09:39:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2D1C01804F1 for ; Thu, 28 Apr 2016 09:39:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.799 X-Spam-Level: * X-Spam-Status: No, score=1.799 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id hXJUyGMARSSm for ; Thu, 28 Apr 2016 09:39:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTP id 013935FB03 for ; Thu, 28 Apr 2016 09:39:04 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EF199E01A7 for ; Thu, 28 Apr 2016 09:39:02 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id DEB1A3A0051 for ; Thu, 28 Apr 2016 09:39:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1741400 - in /httpcomponents/httpcore/trunk/httpcore5/src: main/java/org/apache/hc/core5/http/ main/java/org/apache/hc/core5/http/impl/io/ test/java/org/apache/hc/core5/http/impl/io/ Date: Thu, 28 Apr 2016 09:39:02 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160428093902.DEB1A3A0051@svn01-us-west.apache.org> Author: olegk Date: Thu Apr 28 09:39:02 2016 New Revision: 1741400 URL: http://svn.apache.org/viewvc?rev=1741400&view=rev Log: Added exception to signal an attempt to read to / write from a closed stream Added: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java (with props) Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityOutputStream.java Added: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java?rev=1741400&view=auto ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java (added) +++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java Thu Apr 28 09:39:02 2016 @@ -0,0 +1,43 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.hc.core5.http; + +import java.io.IOException; + +/** + * Signals that data stream has already been closed. + * + * @since 5.0 + */ +public class StreamClosedException extends IOException { + + public StreamClosedException(final String message) { + super(message); + } + +} Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java Thu Apr 28 09:39:02 2016 @@ -35,6 +35,7 @@ import org.apache.hc.core5.http.Connecti import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.MalformedChunkCodingException; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.TruncatedChunkException; import org.apache.hc.core5.http.config.MessageConstraints; import org.apache.hc.core5.http.io.SessionInputBuffer; @@ -139,7 +140,7 @@ public class ChunkedInputStream extends @Override public int read() throws IOException { if (this.closed) { - throw new IOException("Attempted read from closed stream."); + throw new StreamClosedException("Stream already closed"); } if (this.eof) { return -1; @@ -174,7 +175,7 @@ public class ChunkedInputStream extends public int read (final byte[] b, final int off, final int len) throws IOException { if (closed) { - throw new IOException("Attempted read from closed stream."); + throw new StreamClosedException("Stream already closed"); } if (eof) { Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java Thu Apr 28 09:39:02 2016 @@ -33,6 +33,7 @@ import java.io.OutputStream; import org.apache.hc.core5.annotation.NotThreadSafe; import org.apache.hc.core5.http.FormattedHeader; import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.TrailerSupplier; import org.apache.hc.core5.http.io.SessionOutputBuffer; import org.apache.hc.core5.http.message.BasicLineFormatter; @@ -168,7 +169,7 @@ public class ChunkedOutputStream extends @Override public void write(final int b) throws IOException { if (this.closed) { - throw new IOException("Attempted write to closed stream."); + throw new StreamClosedException("Stream already closed"); } this.cache[this.cachePosition] = (byte) b; this.cachePosition++; @@ -193,7 +194,7 @@ public class ChunkedOutputStream extends @Override public void write(final byte[] src, final int off, final int len) throws IOException { if (this.closed) { - throw new IOException("Attempted write to closed stream."); + throw new StreamClosedException("Stream already closed"); } if (len >= this.cache.length - this.cachePosition) { flushCacheWithAppend(src, off, len); Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java Thu Apr 28 09:39:02 2016 @@ -32,6 +32,7 @@ import java.io.InputStream; import org.apache.hc.core5.annotation.NotThreadSafe; import org.apache.hc.core5.http.ConnectionClosedException; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionInputBuffer; import org.apache.hc.core5.util.Args; @@ -125,7 +126,7 @@ public class ContentLengthInputStream ex @Override public int read() throws IOException { if (closed) { - throw new IOException("Attempted read from closed stream."); + throw new StreamClosedException("Stream already closed"); } if (pos >= contentLength) { @@ -159,7 +160,7 @@ public class ContentLengthInputStream ex @Override public int read (final byte[] b, final int off, final int len) throws java.io.IOException { if (closed) { - throw new IOException("Attempted read from closed stream."); + throw new StreamClosedException("Stream already closed"); } if (pos >= contentLength) { Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java Thu Apr 28 09:39:02 2016 @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.hc.core5.annotation.NotThreadSafe; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionOutputBuffer; import org.apache.hc.core5.util.Args; @@ -103,7 +104,7 @@ public class ContentLengthOutputStream e @Override public void write(final byte[] b, final int off, final int len) throws IOException { if (this.closed) { - throw new IOException("Attempted write to closed stream."); + throw new StreamClosedException("Stream already closed"); } if (this.total < this.contentLength) { final long max = this.contentLength - this.total; @@ -124,7 +125,7 @@ public class ContentLengthOutputStream e @Override public void write(final int b) throws IOException { if (this.closed) { - throw new IOException("Attempted write to closed stream."); + throw new StreamClosedException("Stream already closed"); } if (this.total < this.contentLength) { this.buffer.write(b, this.outputStream); Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java Thu Apr 28 09:39:02 2016 @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.InputStream; import org.apache.hc.core5.annotation.NotThreadSafe; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionInputBuffer; import org.apache.hc.core5.util.Args; @@ -79,7 +80,7 @@ public class IdentityInputStream extends @Override public int read() throws IOException { if (this.closed) { - return -1; + throw new StreamClosedException("Stream already closed"); } return this.buffer.read(this.inputStream); } @@ -87,7 +88,7 @@ public class IdentityInputStream extends @Override public int read(final byte[] b, final int off, final int len) throws IOException { if (this.closed) { - return -1; + throw new StreamClosedException("Stream already closed"); } return this.buffer.read(b, off, len, this.inputStream); } Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java Thu Apr 28 09:39:02 2016 @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.hc.core5.annotation.NotThreadSafe; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionOutputBuffer; import org.apache.hc.core5.util.Args; @@ -88,7 +89,7 @@ public class IdentityOutputStream extend @Override public void write(final byte[] b, final int off, final int len) throws IOException { if (this.closed) { - throw new IOException("Attempted write to closed stream."); + throw new StreamClosedException("Stream already closed"); } this.buffer.write(b, off, len, this.outputStream); } @@ -101,7 +102,7 @@ public class IdentityOutputStream extend @Override public void write(final int b) throws IOException { if (this.closed) { - throw new IOException("Attempted write to closed stream."); + throw new StreamClosedException("Stream already closed"); } this.buffer.write(b, this.outputStream); } Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java Thu Apr 28 09:39:02 2016 @@ -37,6 +37,7 @@ import org.apache.hc.core5.http.Connecti import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.MalformedChunkCodingException; import org.apache.hc.core5.http.MessageConstraintException; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.TrailerSupplier; import org.apache.hc.core5.http.TruncatedChunkException; import org.apache.hc.core5.http.config.MessageConstraints; @@ -150,22 +151,19 @@ public class TestChunkCoding { in.close(); try { in.read(); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } final byte[] tmp = new byte[10]; try { in.read(tmp); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } try { in.read(tmp, 0, tmp.length); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } } Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthInputStream.java Thu Apr 28 09:39:02 2016 @@ -34,6 +34,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import org.apache.hc.core5.http.ConnectionClosedException; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionInputBuffer; import org.junit.Assert; import org.junit.Test; @@ -116,22 +117,19 @@ public class TestContentLengthInputStrea in.close(); try { in.read(); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } final byte[] tmp = new byte[10]; try { in.read(tmp); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } try { in.read(tmp, 0, tmp.length); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } Assert.assertEquals('-', inbuffer.read(inputStream)); } Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestContentLengthOutputStream.java Thu Apr 28 09:39:02 2016 @@ -28,9 +28,9 @@ package org.apache.hc.core5.http.impl.io; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.OutputStream; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionOutputBuffer; import org.junit.Assert; import org.junit.Test; @@ -67,15 +67,13 @@ public class TestContentLengthOutputStre final byte[] tmp = new byte[10]; try { out.write(tmp); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } try { out.write(1); - Assert.fail("IOException should have been thrown"); - } catch (final IOException ex) { - // expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } } Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityInputStream.java Thu Apr 28 09:39:02 2016 @@ -29,6 +29,7 @@ package org.apache.hc.core5.http.impl.io import java.io.ByteArrayInputStream; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionInputBuffer; import org.junit.Assert; import org.junit.Test; @@ -68,10 +69,16 @@ public class TestIdentityInputStream { Assert.assertEquals(0, in.available()); final byte[] tmp = new byte[2]; - Assert.assertEquals(-1, in.read(tmp, 0, tmp.length)); - Assert.assertEquals(-1, in.read()); - Assert.assertEquals(-1, in.read(tmp, 0, tmp.length)); - Assert.assertEquals(-1, in.read()); + try { + in.read(tmp, 0, tmp.length); + Assert.fail("StreamClosedException expected"); + } catch (StreamClosedException expected) { + } + try { + in.read(); + Assert.fail("StreamClosedException expected"); + } catch (StreamClosedException expected) { + } } @Test Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityOutputStream.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityOutputStream.java?rev=1741400&r1=1741399&r2=1741400&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityOutputStream.java (original) +++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestIdentityOutputStream.java Thu Apr 28 09:39:02 2016 @@ -31,6 +31,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import org.apache.hc.core5.http.StreamClosedException; import org.apache.hc.core5.http.io.SessionOutputBuffer; import org.junit.Assert; import org.junit.Test; @@ -109,15 +110,13 @@ public class TestIdentityOutputStream { try { final byte[] tmp = new byte[2]; out.write(tmp, 0, tmp.length); - Assert.fail("IOException should have been thrown"); - } catch (final IOException e) { - //expected + Assert.fail("StreamClosedException expected"); + } catch (final StreamClosedException expected) { } try { out.write('a'); - Assert.fail("IOException should have been thrown"); - } catch (final IOException e) { - //expected + Assert.fail("StreamClosedException expected"); + } catch (final IOException expected) { } }