diff -Nru httpcomponents-core-4.3.2/debian/changelog httpcomponents-core-4.3.3/debian/changelog --- httpcomponents-core-4.3.2/debian/changelog 2014-04-01 00:07:25.000000000 +0000 +++ httpcomponents-core-4.3.3/debian/changelog 2014-10-25 21:15:42.000000000 +0000 @@ -1,3 +1,11 @@ +httpcomponents-core (4.3.3-1) unstable; urgency=medium + + * New upstream release + * Ignore the apache-rat-plugin + * Standards-Version updated to 3.9.6 (no changes) + + -- Emmanuel Bourg Sat, 25 Oct 2014 23:01:10 +0200 + httpcomponents-core (4.3.2-2) unstable; urgency=low * Team upload. diff -Nru httpcomponents-core-4.3.2/debian/control httpcomponents-core-4.3.3/debian/control --- httpcomponents-core-4.3.2/debian/control 2014-04-01 00:03:41.000000000 +0000 +++ httpcomponents-core-4.3.3/debian/control 2014-10-25 20:54:15.000000000 +0000 @@ -10,9 +10,9 @@ libmaven-antrun-plugin-java, libmaven-bundle-plugin-java, maven-debian-helper -Standards-Version: 3.9.5 +Standards-Version: 3.9.6 Vcs-Git: git://anonscm.debian.org/pkg-java/httpcomponents-core.git -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-java/httpcomponents-core.git +Vcs-Browser: http://anonscm.debian.org/cgit/pkg-java/httpcomponents-core.git Homepage: http://hc.apache.org/httpcomponents-core-ga/index.html Package: libhttpcore-java diff -Nru httpcomponents-core-4.3.2/debian/maven.ignoreRules httpcomponents-core-4.3.3/debian/maven.ignoreRules --- httpcomponents-core-4.3.2/debian/maven.ignoreRules 2014-04-01 00:03:41.000000000 +0000 +++ httpcomponents-core-4.3.3/debian/maven.ignoreRules 2014-10-25 21:15:13.000000000 +0000 @@ -31,6 +31,7 @@ org.apache.maven.plugins maven-source-plugin * * * * org.apache.maven.plugins maven-surefire-plugin * * * * org.apache.maven.plugins maven-surefire-report-plugin * * * * +org.apache.rat apache-rat-plugin * * * * org.codehaus.mojo clirr-maven-plugin * * * * org.docbook docbook-xml * * * * org.mockito mockito-core * * * * diff -Nru httpcomponents-core-4.3.2/httpcore/pom.xml httpcomponents-core-4.3.3/httpcore/pom.xml --- httpcomponents-core-4.3.2/httpcore/pom.xml 2014-02-12 20:35:34.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/pom.xml 2014-10-18 11:42:51.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-core - 4.3.2 + 4.3.3 httpcore Apache HttpCore diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/config/RegistryBuilder.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/config/RegistryBuilder.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/config/RegistryBuilder.java 2014-02-12 20:35:31.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/config/RegistryBuilder.java 2014-10-18 11:42:53.000000000 +0000 @@ -56,7 +56,7 @@ public RegistryBuilder register(final String id, final I item) { Args.notEmpty(id, "ID"); Args.notNull(item, "Item"); - items.put(id.toLowerCase(Locale.US), item); + items.put(id.toLowerCase(Locale.ENGLISH), item); return this; } diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/config/Registry.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/config/Registry.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/config/Registry.java 2014-02-12 20:35:31.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/config/Registry.java 2014-10-18 11:42:53.000000000 +0000 @@ -52,7 +52,7 @@ if (key == null) { return null; } - return map.get(key.toLowerCase(Locale.US)); + return map.get(key.toLowerCase(Locale.ENGLISH)); } @Override diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/entity/AbstractHttpEntity.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/entity/AbstractHttpEntity.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/entity/AbstractHttpEntity.java 2014-02-12 20:35:32.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/entity/AbstractHttpEntity.java 2014-10-18 11:42:54.000000000 +0000 @@ -188,4 +188,30 @@ public void consumeContent() throws IOException { } + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append('['); + if (contentType != null) { + sb.append("Content-Type: "); + sb.append(contentType.getValue()); + sb.append(','); + } + if (contentEncoding != null) { + sb.append("Content-Encoding: "); + sb.append(contentEncoding.getValue()); + sb.append(','); + } + final long len = getContentLength(); + if (len >= 0) { + sb.append("Content-Length: "); + sb.append(len); + sb.append(','); + } + sb.append("Chunked: "); + sb.append(chunked); + sb.append(']'); + return sb.toString(); + } + } diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/entity/ContentType.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/entity/ContentType.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/entity/ContentType.java 2014-02-12 20:35:32.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/entity/ContentType.java 2014-10-18 11:42:54.000000000 +0000 @@ -172,7 +172,7 @@ * @return content type */ public static ContentType create(final String mimeType, final Charset charset) { - final String type = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.US); + final String type = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.ENGLISH); Args.check(valid(type), "MIME type may not contain reserved characters"); return new ContentType(type, charset); } diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java 2014-02-12 20:35:33.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java 2014-10-18 11:42:55.000000000 +0000 @@ -37,6 +37,7 @@ import java.net.SocketTimeoutException; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; +import java.util.concurrent.atomic.AtomicReference; import org.apache.http.Header; import org.apache.http.HttpConnection; @@ -81,9 +82,7 @@ private final HttpConnectionMetricsImpl connMetrics; private final ContentLengthStrategy incomingContentStrategy; private final ContentLengthStrategy outgoingContentStrategy; - - private volatile boolean open; - private volatile Socket socket; + private final AtomicReference socketHolder; /** * Creates new instance of BHttpConnectionBase. @@ -122,15 +121,17 @@ LaxContentLengthStrategy.INSTANCE; this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy : StrictContentLengthStrategy.INSTANCE; + this.socketHolder = new AtomicReference(); } protected void ensureOpen() throws IOException { - Asserts.check(this.open, "Connection is not open"); + final Socket socket = this.socketHolder.get(); + Asserts.check(socket != null, "Connection is not open"); if (!this.inbuffer.isBound()) { - this.inbuffer.bind(getSocketInputStream(this.socket)); + this.inbuffer.bind(getSocketInputStream(socket)); } if (!this.outbuffer.isBound()) { - this.outbuffer.bind(getSocketOutputStream(this.socket)); + this.outbuffer.bind(getSocketOutputStream(socket)); } } @@ -154,8 +155,7 @@ */ protected void bind(final Socket socket) throws IOException { Args.notNull(socket, "Socket"); - this.socket = socket; - this.open = true; + this.socketHolder.set(socket); this.inbuffer.bind(null); this.outbuffer.bind(null); } @@ -173,11 +173,11 @@ } public boolean isOpen() { - return this.open; + return this.socketHolder.get() != null; } protected Socket getSocket() { - return this.socket; + return this.socketHolder.get(); } protected OutputStream createOutputStream( @@ -240,41 +240,30 @@ } public InetAddress getLocalAddress() { - if (this.socket != null) { - return this.socket.getLocalAddress(); - } else { - return null; - } + final Socket socket = this.socketHolder.get(); + return socket != null ? socket.getLocalAddress() : null; } public int getLocalPort() { - if (this.socket != null) { - return this.socket.getLocalPort(); - } else { - return -1; - } + final Socket socket = this.socketHolder.get(); + return socket != null ? socket.getLocalPort() : -1; } public InetAddress getRemoteAddress() { - if (this.socket != null) { - return this.socket.getInetAddress(); - } else { - return null; - } + final Socket socket = this.socketHolder.get(); + return socket != null ? socket.getInetAddress() : null; } public int getRemotePort() { - if (this.socket != null) { - return this.socket.getPort(); - } else { - return -1; - } + final Socket socket = this.socketHolder.get(); + return socket != null ? socket.getPort() : -1; } public void setSocketTimeout(final int timeout) { - if (this.socket != null) { + final Socket socket = this.socketHolder.get(); + if (socket != null) { try { - this.socket.setSoTimeout(timeout); + socket.setSoTimeout(timeout); } catch (final SocketException ignore) { // It is not quite clear from the Sun's documentation if there are any // other legitimate cases for a socket exception to be thrown when setting @@ -284,9 +273,10 @@ } public int getSocketTimeout() { - if (this.socket != null) { + final Socket socket = this.socketHolder.get(); + if (socket != null) { try { - return this.socket.getSoTimeout(); + return socket.getSoTimeout(); } catch (final SocketException ignore) { return -1; } @@ -296,46 +286,44 @@ } public void shutdown() throws IOException { - this.open = false; - final Socket tmpsocket = this.socket; - if (tmpsocket != null) { - tmpsocket.close(); + final Socket socket = this.socketHolder.getAndSet(null); + if (socket != null) { + socket.close(); } } public void close() throws IOException { - if (!this.open) { - return; - } - this.open = false; - final Socket sock = this.socket; - try { - this.inbuffer.clear(); - this.outbuffer.flush(); + final Socket socket = this.socketHolder.getAndSet(null); + if (socket != null) { try { + this.inbuffer.clear(); + this.outbuffer.flush(); try { - sock.shutdownOutput(); - } catch (final IOException ignore) { - } - try { - sock.shutdownInput(); - } catch (final IOException ignore) { + try { + socket.shutdownOutput(); + } catch (final IOException ignore) { + } + try { + socket.shutdownInput(); + } catch (final IOException ignore) { + } + } catch (final UnsupportedOperationException ignore) { + // if one isn't supported, the other one isn't either } - } catch (final UnsupportedOperationException ignore) { - // if one isn't supported, the other one isn't either + } finally { + socket.close(); } - } finally { - sock.close(); } } private int fillInputBuffer(final int timeout) throws IOException { - final int oldtimeout = this.socket.getSoTimeout(); + final Socket socket = this.socketHolder.get(); + final int oldtimeout = socket.getSoTimeout(); try { - this.socket.setSoTimeout(timeout); + socket.setSoTimeout(timeout); return this.inbuffer.fillBuffer(); } finally { - this.socket.setSoTimeout(oldtimeout); + socket.setSoTimeout(oldtimeout); } } @@ -375,10 +363,11 @@ @Override public String toString() { - if (this.socket != null) { + final Socket socket = this.socketHolder.get(); + if (socket != null) { final StringBuilder buffer = new StringBuilder(); - final SocketAddress remoteAddress = this.socket.getRemoteSocketAddress(); - final SocketAddress localAddress = this.socket.getLocalSocketAddress(); + final SocketAddress remoteAddress = socket.getRemoteSocketAddress(); + final SocketAddress localAddress = socket.getLocalSocketAddress(); if (remoteAddress != null && localAddress != null) { NetUtils.formatAddress(buffer, localAddress); buffer.append("<->"); diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java 2014-02-12 20:35:33.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/impl/pool/BasicConnFactory.java 2014-10-18 11:42:55.000000000 +0000 @@ -164,13 +164,13 @@ } } socket.setSoTimeout(this.sconfig.getSoTimeout()); - socket.connect(new InetSocketAddress(hostname, port), this.connectTimeout); socket.setTcpNoDelay(this.sconfig.isTcpNoDelay()); final int linger = this.sconfig.getSoLinger(); if (linger >= 0) { socket.setSoLinger(linger > 0, linger); } socket.setKeepAlive(this.sconfig.isSoKeepAlive()); + socket.connect(new InetSocketAddress(hostname, port), this.connectTimeout); return this.connFactory.createConnection(socket); } diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java 2014-02-12 20:35:33.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/message/BasicHttpRequest.java 2014-10-18 11:42:55.000000000 +0000 @@ -108,7 +108,7 @@ @Override public String toString() { - return this.method + " " + this.uri + " " + this.headergroup; + return this.method + ' ' + this.uri + ' ' + this.headergroup; } } diff -Nru httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java --- httpcomponents-core-4.3.2/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java 2014-02-12 20:35:33.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/main/java/org/apache/http/message/BasicHttpResponse.java 2014-10-18 11:42:55.000000000 +0000 @@ -192,7 +192,7 @@ } public void setLocale(final Locale locale) { - this.locale = Args.notNull(locale, "Locale"); + this.locale = Args.notNull(locale, "Locale"); this.statusline = null; } @@ -212,7 +212,15 @@ @Override public String toString() { - return getStatusLine() + " " + this.headergroup; + final StringBuilder sb = new StringBuilder(); + sb.append(getStatusLine()); + sb.append(' '); + sb.append(this.headergroup); + if (this.entity != null) { + sb.append(' '); + sb.append(this.entity); + } + return sb.toString(); } } diff -Nru httpcomponents-core-4.3.2/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java httpcomponents-core-4.3.3/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java --- httpcomponents-core-4.3.2/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java 2014-02-12 20:35:28.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java 2014-10-18 11:42:51.000000000 +0000 @@ -165,7 +165,7 @@ Mockito.verify(socket, Mockito.times(1)).close(); conn.shutdown(); - Mockito.verify(socket, Mockito.times(2)).close(); + Mockito.verify(socket, Mockito.times(1)).close(); } @Test diff -Nru httpcomponents-core-4.3.2/httpcore-ab/pom.xml httpcomponents-core-4.3.3/httpcore-ab/pom.xml --- httpcomponents-core-4.3.2/httpcore-ab/pom.xml 2014-02-12 20:35:34.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-ab/pom.xml 2014-10-18 11:42:56.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-core - 4.3.2 + 4.3.3 httpcore-ab Apache HttpCore Benchmarking Tool diff -Nru httpcomponents-core-4.3.2/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java httpcomponents-core-4.3.3/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java --- httpcomponents-core-4.3.2/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java 2014-02-12 20:35:34.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java 2014-10-18 11:42:56.000000000 +0000 @@ -90,7 +90,7 @@ new RequestTargetHost(), new RequestConnControl(), new RequestUserAgent("HttpCore-AB/1.1"), - new RequestExpectContinue(true)); + new RequestExpectContinue(this.config.isUseExpectContinue())); this.httpexecutor = new HttpRequestExecutor(); this.connstrategy = DefaultConnectionReuseStrategy.INSTANCE; diff -Nru httpcomponents-core-4.3.2/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java httpcomponents-core-4.3.3/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java --- httpcomponents-core-4.3.2/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java 2014-02-12 20:35:34.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-ab/src/main/java/org/apache/http/benchmark/HttpBenchmark.java 2014-10-18 11:42:56.000000000 +0000 @@ -51,6 +51,7 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; +import org.apache.http.HttpVersion; import org.apache.http.entity.ContentType; import org.apache.http.entity.FileEntity; import org.apache.http.entity.StringEntity; @@ -112,15 +113,16 @@ se.setChunked(config.isUseChunking()); entity = se; } + final HttpVersion ver = config.isUseHttp1_0() ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1; final HttpRequest request; if ("POST".equals(config.getMethod())) { final BasicHttpEntityEnclosingRequest httppost = - new BasicHttpEntityEnclosingRequest("POST", url.getPath()); + new BasicHttpEntityEnclosingRequest("POST", url.getPath(), ver); httppost.setEntity(entity); request = httppost; } else if ("PUT".equals(config.getMethod())) { final BasicHttpEntityEnclosingRequest httpput = - new BasicHttpEntityEnclosingRequest("PUT", url.getPath()); + new BasicHttpEntityEnclosingRequest("PUT", url.getPath(), ver); httpput.setEntity(entity); request = httpput; } else { @@ -130,7 +132,7 @@ } else if (path.trim().length() == 0) { path = "/"; } - request = new BasicHttpRequest(config.getMethod(), path); + request = new BasicHttpRequest(config.getMethod(), path, ver); } if (!config.isKeepAlive()) { diff -Nru httpcomponents-core-4.3.2/httpcore-nio/pom.xml httpcomponents-core-4.3.3/httpcore-nio/pom.xml --- httpcomponents-core-4.3.2/httpcore-nio/pom.xml 2014-02-12 20:35:37.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/pom.xml 2014-10-18 11:42:59.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-core - 4.3.2 + 4.3.3 httpcore-nio Apache HttpCore NIO diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java 2014-10-18 11:42:58.000000000 +0000 @@ -245,7 +245,6 @@ */ protected void bind(final IOSession session) { Args.notNull(session, "I/O session"); - this.session.setBufferStatus(null); setSession(session); } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java 2014-10-18 11:42:58.000000000 +0000 @@ -40,6 +40,7 @@ import java.util.Date; import java.util.List; import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicLong; import org.apache.http.annotation.ThreadSafe; import org.apache.http.nio.params.NIOReactorPNames; @@ -548,6 +549,7 @@ if (this.status.compareTo(IOReactorStatus.INACTIVE) == 0) { this.status = IOReactorStatus.SHUT_DOWN; cancelRequests(); + this.selector.close(); return; } this.status = IOReactorStatus.SHUTDOWN_REQUEST; @@ -595,10 +597,10 @@ static class DefaultThreadFactory implements ThreadFactory { - private static volatile int COUNT = 0; + private final static AtomicLong COUNT = new AtomicLong(1); public Thread newThread(final Runnable r) { - return new Thread(r, "I/O dispatcher " + (++COUNT)); + return new Thread(r, "I/O dispatcher " + COUNT.getAndIncrement()); } } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java 2014-10-18 11:42:58.000000000 +0000 @@ -259,16 +259,17 @@ throw new IOReactorException("Failure opening socket", ex); } try { - socketChannel.configureBlocking(false); validateAddress(request.getLocalAddress()); validateAddress(request.getRemoteAddress()); + socketChannel.configureBlocking(false); + prepareSocket(socketChannel.socket()); + if (request.getLocalAddress() != null) { final Socket sock = socketChannel.socket(); sock.setReuseAddress(this.config.isSoReuseAddress()); sock.bind(request.getLocalAddress()); } - prepareSocket(socketChannel.socket()); final boolean connected = socketChannel.connect(request.getRemoteAddress()); if (connected) { final ChannelEntry entry = new ChannelEntry(socketChannel, request); diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java 2014-02-12 20:35:37.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java 2014-10-18 11:42:58.000000000 +0000 @@ -92,4 +92,9 @@ } } + @Override + public String toString() { + return this.entity.toString(); + } + } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java 2014-10-18 11:42:59.000000000 +0000 @@ -47,6 +47,7 @@ import org.apache.http.concurrent.BasicFuture; import org.apache.http.concurrent.FutureCallback; import org.apache.http.nio.reactor.ConnectingIOReactor; +import org.apache.http.nio.reactor.IOReactorStatus; import org.apache.http.nio.reactor.IOSession; import org.apache.http.nio.reactor.SessionRequest; import org.apache.http.nio.reactor.SessionRequestCallback; @@ -506,7 +507,9 @@ this.pending.remove(request); final RouteSpecificPool pool = getPool(route); pool.cancelled(request); - processNextPendingRequest(); + if (this.ioreactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) { + processNextPendingRequest(); + } } finally { this.lock.unlock(); } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/pool/RouteSpecificPool.java 2014-10-18 11:42:59.000000000 +0000 @@ -26,7 +26,7 @@ */ package org.apache.http.nio.pool; -import java.net.SocketTimeoutException; +import java.net.ConnectException; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -167,7 +167,7 @@ public void timeout(final SessionRequest request) { final BasicFuture future = removeRequest(request); - future.failed(new SocketTimeoutException()); + future.failed(new ConnectException()); } public void shutdown() { diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java 2014-10-18 11:42:59.000000000 +0000 @@ -27,12 +27,12 @@ package org.apache.http.nio.protocol; import java.io.IOException; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; import org.apache.http.entity.ContentType; import org.apache.http.nio.ContentDecoder; import org.apache.http.nio.IOControl; @@ -40,20 +40,21 @@ /** * Abstract {@link HttpAsyncRequestConsumer} implementation that relieves its - * subclasses form having to synchronize access to internal instance variables - * and provides a number of protected methods that they need to implement. + * subclasses from having to manage internal state and provides a number of protected + * event methods that they need to implement. * * @since 4.2 */ -@ThreadSafe public abstract class AbstractAsyncRequestConsumer implements HttpAsyncRequestConsumer { - private volatile boolean completed; + private final AtomicBoolean completed; + private volatile T result; private volatile Exception ex; public AbstractAsyncRequestConsumer() { super(); + this.completed = new AtomicBoolean(false); } /** @@ -122,7 +123,7 @@ /** * Use {@link #onRequestReceived(HttpRequest)} instead. */ - public final synchronized void requestReceived( + public final void requestReceived( final HttpRequest request) throws HttpException, IOException { onRequestReceived(request); if (request instanceof HttpEntityEnclosingRequest) { @@ -137,7 +138,7 @@ /** * Use {@link #onContentReceived(ContentDecoder, IOControl)} instead. */ - public final synchronized void consumeContent( + public final void consumeContent( final ContentDecoder decoder, final IOControl ioctrl) throws IOException { onContentReceived(decoder, ioctrl); } @@ -145,36 +146,30 @@ /** * Use {@link #buildResult(HttpContext)} instead. */ - public final synchronized void requestCompleted(final HttpContext context) { - if (this.completed) { - return; - } - this.completed = true; - try { - this.result = buildResult(context); - } catch (final Exception ex) { - this.ex = ex; - } finally { - releaseResources(); + public final void requestCompleted(final HttpContext context) { + if (this.completed.compareAndSet(false, true)) { + try { + this.result = buildResult(context); + } catch (final Exception ex) { + this.ex = ex; + } finally { + releaseResources(); + } } } - public final synchronized void failed(final Exception ex) { - if (this.completed) { - return; + public final void failed(final Exception ex) { + if (this.completed.compareAndSet(false, true)) { + this.ex = ex; + releaseResources(); } - this.completed = true; - this.ex = ex; - releaseResources(); } - public final synchronized void close() throws IOException { - if (this.completed) { - return; + public final void close() throws IOException { + if (this.completed.compareAndSet(false, true)) { + releaseResources(); + onClose(); } - this.completed = true; - releaseResources(); - onClose(); } public Exception getException() { @@ -186,7 +181,7 @@ } public boolean isDone() { - return this.completed; + return this.completed.get(); } } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java 2014-10-18 11:42:59.000000000 +0000 @@ -27,11 +27,11 @@ package org.apache.http.nio.protocol; import java.io.IOException; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.http.HttpEntity; import org.apache.http.HttpException; import org.apache.http.HttpResponse; -import org.apache.http.annotation.ThreadSafe; import org.apache.http.entity.ContentType; import org.apache.http.nio.ContentDecoder; import org.apache.http.nio.IOControl; @@ -39,20 +39,21 @@ /** * Abstract {@link HttpAsyncResponseConsumer} implementation that relieves its - * subclasses form having to synchronize access to internal instance variables - * and provides a number of protected methods that they need to implement. + * subclasses from having to manage internal state and provides a number of protected + * event methods that they need to implement. * * @since 4.2 */ -@ThreadSafe public abstract class AbstractAsyncResponseConsumer implements HttpAsyncResponseConsumer { - private volatile boolean completed; + private final AtomicBoolean completed; + private volatile T result; private volatile Exception ex; public AbstractAsyncResponseConsumer() { super(); + this.completed = new AtomicBoolean(false); } /** @@ -120,7 +121,7 @@ /** * Use {@link #onResponseReceived(HttpResponse)} instead. */ - public final synchronized void responseReceived( + public final void responseReceived( final HttpResponse response) throws IOException, HttpException { onResponseReceived(response); final HttpEntity entity = response.getEntity(); @@ -133,7 +134,7 @@ /** * Use {@link #onContentReceived(ContentDecoder, IOControl)} instead. */ - public final synchronized void consumeContent( + public final void consumeContent( final ContentDecoder decoder, final IOControl ioctrl) throws IOException { onContentReceived(decoder, ioctrl); } @@ -141,45 +142,38 @@ /** * Use {@link #buildResult(HttpContext)} instead. */ - public final synchronized void responseCompleted(final HttpContext context) { - if (this.completed) { - return; - } - this.completed = true; - try { - this.result = buildResult(context); - } catch (final Exception ex) { - this.ex = ex; - } finally { - releaseResources(); + public final void responseCompleted(final HttpContext context) { + if (this.completed.compareAndSet(false, true)) { + try { + this.result = buildResult(context); + } catch (final Exception ex) { + this.ex = ex; + } finally { + releaseResources(); + } } } - public final synchronized boolean cancel() { - if (this.completed) { - return false; + public final boolean cancel() { + if (this.completed.compareAndSet(false, true)) { + releaseResources(); + return true; } - this.completed = true; - releaseResources(); - return true; + return false; } - public final synchronized void failed(final Exception ex) { - if (this.completed) { - return; + public final void failed(final Exception ex) { + if (this.completed.compareAndSet(false, true)) { + this.ex = ex; + releaseResources(); } - this.completed = true; - this.ex = ex; - releaseResources(); } - public final synchronized void close() throws IOException { - if (this.completed) { - return; + public final void close() throws IOException { + if (this.completed.compareAndSet(false, true)) { + releaseResources(); + onClose(); } - this.completed = true; - releaseResources(); - onClose(); } public Exception getException() { @@ -191,7 +185,7 @@ } public boolean isDone() { - return this.completed; + return this.completed.get(); } } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java 2014-10-18 11:42:59.000000000 +0000 @@ -32,7 +32,6 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; import org.apache.http.entity.ContentType; import org.apache.http.nio.ContentDecoder; import org.apache.http.nio.IOControl; @@ -49,7 +48,6 @@ * * @since 4.2 */ -@ThreadSafe public class BasicAsyncRequestConsumer extends AbstractAsyncRequestConsumer { private volatile HttpRequest request; diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java 2014-10-18 11:42:59.000000000 +0000 @@ -32,7 +32,6 @@ import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; -import org.apache.http.annotation.ThreadSafe; import org.apache.http.nio.ContentEncoder; import org.apache.http.nio.IOControl; import org.apache.http.nio.entity.EntityAsyncContentProducer; @@ -50,7 +49,6 @@ * * @since 4.2 */ -@ThreadSafe public class BasicAsyncRequestProducer implements HttpAsyncRequestProducer { private final HttpHost target; @@ -110,7 +108,7 @@ } } - public synchronized HttpRequest generateRequest() { + public HttpRequest generateRequest() { return this.request; } @@ -118,7 +116,7 @@ return this.target; } - public synchronized void produceContent( + public void produceContent( final ContentEncoder encoder, final IOControl ioctrl) throws IOException { if (this.producer != null) { this.producer.produceContent(encoder, ioctrl); @@ -134,20 +132,33 @@ public void failed(final Exception ex) { } - public synchronized boolean isRepeatable() { + public boolean isRepeatable() { return this.producer == null || this.producer.isRepeatable(); } - public synchronized void resetRequest() throws IOException { + public void resetRequest() throws IOException { if (this.producer != null) { this.producer.close(); } } - public synchronized void close() throws IOException { + public void close() throws IOException { if (this.producer != null) { this.producer.close(); } } + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append(this.target); + sb.append(' '); + sb.append(this.request); + if (this.producer != null) { + sb.append(' '); + sb.append(this.producer); + } + return sb.toString(); + } + } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java 2014-10-18 11:42:59.000000000 +0000 @@ -31,7 +31,6 @@ import org.apache.http.ContentTooLongException; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; -import org.apache.http.annotation.ThreadSafe; import org.apache.http.entity.ContentType; import org.apache.http.nio.ContentDecoder; import org.apache.http.nio.IOControl; @@ -48,7 +47,6 @@ * * @since 4.2 */ -@ThreadSafe public class BasicAsyncResponseConsumer extends AbstractAsyncResponseConsumer { private volatile HttpResponse response; diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java 2014-10-18 11:42:59.000000000 +0000 @@ -31,7 +31,6 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; -import org.apache.http.annotation.ThreadSafe; import org.apache.http.nio.ContentEncoder; import org.apache.http.nio.IOControl; import org.apache.http.nio.entity.EntityAsyncContentProducer; @@ -43,14 +42,13 @@ * Basic implementation of {@link HttpAsyncResponseProducer}. The producer * can make use of the {@link HttpAsyncContentProducer} interface to * efficiently stream out message content to the underlying non-blocking HTTP - * connection, if it is implemented by the {@link HttpEntity} inclosed in + * connection, if it is implemented by the {@link HttpEntity} enclosed in * the response. * * @see HttpAsyncContentProducer * * @since 4.2 */ -@ThreadSafe public class BasicAsyncResponseProducer implements HttpAsyncResponseProducer { private final HttpResponse response; @@ -99,11 +97,11 @@ } } - public synchronized HttpResponse generateResponse() { + public HttpResponse generateResponse() { return this.response; } - public synchronized void produceContent( + public void produceContent( final ContentEncoder encoder, final IOControl ioctrl) throws IOException { if (this.producer != null) { this.producer.produceContent(encoder, ioctrl); @@ -119,10 +117,20 @@ public void failed(final Exception ex) { } - public synchronized void close() throws IOException { + public void close() throws IOException { if (this.producer != null) { this.producer.close(); } } + @Override + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append(this.response); + if (this.producer != null) { + buf.append(" ").append(this.producer); + } + return buf.toString(); + } + } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java 2014-10-18 11:42:59.000000000 +0000 @@ -107,12 +107,16 @@ public void closed(final NHttpClientConnection conn) { final State state = getState(conn); final HttpAsyncClientExchangeHandler handler = getHandler(conn); + if (state != null) { + if (state.getRequestState() != MessageState.READY || state.getResponseState() != MessageState.READY) { + if (handler != null) { + handler.failed(new ConnectionClosedException("Connection closed unexpectedly")); + } + } + } if (state == null || (handler != null && handler.isDone())) { closeHandler(handler); } - if (state != null) { - state.reset(); - } } public void exception( diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java --- httpcomponents-core-4.3.2/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java 2014-02-12 20:35:36.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java 2014-10-18 11:42:59.000000000 +0000 @@ -237,7 +237,7 @@ || state.getResponseState().compareTo(MessageState.INIT) > 0) { // There is not much that we can do if a response // has already been submitted - closeConnection(conn); + shutdownConnection(conn); } else { final HttpContext context = state.getContext(); final HttpAsyncResponseProducer responseProducer = handleException( diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestClientOutOfSequenceResponse.java httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestClientOutOfSequenceResponse.java --- httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestClientOutOfSequenceResponse.java 2014-02-12 20:35:34.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestClientOutOfSequenceResponse.java 2014-10-18 11:42:57.000000000 +0000 @@ -32,7 +32,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import org.apache.http.Consts; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; @@ -89,7 +88,7 @@ socket.getOutputStream().write(( "HTTP/1.1 200 OK\r\n" + "Content-Length: 0\r\n" + - "Connection: keep-alive\r\n\r\n").getBytes(Consts.UTF_8)); + "Connection: keep-alive\r\n\r\n").getBytes("UTF-8")); socket.getOutputStream().flush(); } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java --- httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java 2014-10-18 11:42:56.000000000 +0000 @@ -29,7 +29,7 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; -import java.net.SocketTimeoutException; +import java.net.ConnectException; import java.net.UnknownHostException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -37,6 +37,7 @@ import org.apache.http.concurrent.BasicFuture; import org.apache.http.nio.reactor.ConnectingIOReactor; +import org.apache.http.nio.reactor.IOReactorStatus; import org.apache.http.nio.reactor.IOSession; import org.apache.http.nio.reactor.SessionRequest; import org.apache.http.nio.reactor.SessionRequestCallback; @@ -240,6 +241,7 @@ Mockito.any(SocketAddress.class), Mockito.any(), Mockito.any(SessionRequestCallback.class))). thenReturn(sessionRequest); + Mockito.when(ioreactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE); final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10); final Future future = pool.lease("somehost", null); @@ -289,7 +291,7 @@ future.get(); Assert.fail("ExecutionException should have been thrown"); } catch (final ExecutionException ex) { - Assert.assertTrue(ex.getCause() instanceof SocketTimeoutException); + Assert.assertTrue(ex.getCause() instanceof ConnectException); } totals = pool.getTotalStats(); diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestRouteSpecificPool.java httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestRouteSpecificPool.java --- httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestRouteSpecificPool.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestRouteSpecificPool.java 2014-10-18 11:42:56.000000000 +0000 @@ -27,7 +27,7 @@ package org.apache.http.nio.pool; import java.io.IOException; -import java.net.SocketTimeoutException; +import java.net.ConnectException; import java.util.concurrent.ExecutionException; import org.apache.http.concurrent.BasicFuture; @@ -171,7 +171,7 @@ future.get(); Assert.fail("ExecutionException should have been thrown"); } catch (final ExecutionException ex) { - Assert.assertTrue(ex.getCause() instanceof SocketTimeoutException); + Assert.assertTrue(ex.getCause() instanceof ConnectException); } Assert.assertEquals(0, pool.getAllocatedCount()); Assert.assertEquals(0, pool.getAvailableCount()); diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestProducer.java httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestProducer.java --- httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestProducer.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestProducer.java 2014-10-18 11:42:57.000000000 +0000 @@ -128,4 +128,9 @@ verify(contentProducer, times(1)).close(); } + @Test + public void testToString() { + Assert.assertEquals(target + " " + request + " " + contentProducer, producer.toString()); + } + } diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java --- httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequestExecutor.java 2014-10-18 11:42:57.000000000 +0000 @@ -101,15 +101,13 @@ @Test public void testClosed() throws Exception { final State state = new HttpAsyncRequestExecutor.State(); - state.setRequestState(MessageState.COMPLETED); - state.setResponseState(MessageState.COMPLETED); + state.setRequestState(MessageState.READY); + state.setResponseState(MessageState.READY); this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state); this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler); this.protocolHandler.closed(this.conn); - Assert.assertEquals(MessageState.READY, state.getRequestState()); - Assert.assertEquals(MessageState.READY, state.getResponseState()); Mockito.verify(this.exchangeHandler, Mockito.never()).close(); } @@ -123,6 +121,19 @@ } @Test + public void testClosedInconsistentState() throws Exception { + final State state = new HttpAsyncRequestExecutor.State(); + state.setRequestState(MessageState.COMPLETED); + state.setResponseState(MessageState.INIT); + this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_EXCHANGE_STATE, state); + this.connContext.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this.exchangeHandler); + + this.protocolHandler.closed(this.conn); + + Mockito.verify(this.exchangeHandler).failed(Mockito.any(ConnectionClosedException.class)); + } + + @Test public void testHttpExceptionHandling() throws Exception { final State state = new HttpAsyncRequestExecutor.State(); state.setRequestState(MessageState.COMPLETED); diff -Nru httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java --- httpcomponents-core-4.3.2/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java 2014-02-12 20:35:35.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java 2014-10-18 11:42:57.000000000 +0000 @@ -230,7 +230,7 @@ Assert.assertEquals(MessageState.READY, state.getRequestState()); Assert.assertEquals(MessageState.READY, state.getResponseState()); - Mockito.verify(this.conn).close(); + Mockito.verify(this.conn).shutdown(); Mockito.verify(this.requestConsumer).failed(httpex); Mockito.verify(this.requestConsumer).close(); Mockito.verify(this.responseProducer).failed(httpex); diff -Nru httpcomponents-core-4.3.2/httpcore-osgi/pom.xml httpcomponents-core-4.3.3/httpcore-osgi/pom.xml --- httpcomponents-core-4.3.2/httpcore-osgi/pom.xml 2014-02-12 20:35:26.000000000 +0000 +++ httpcomponents-core-4.3.3/httpcore-osgi/pom.xml 2014-10-18 11:42:50.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-core - 4.3.2 + 4.3.3 httpcore-osgi Apache HttpCore OSGi bundle diff -Nru httpcomponents-core-4.3.2/pom.xml httpcomponents-core-4.3.3/pom.xml --- httpcomponents-core-4.3.2/pom.xml 2014-02-12 20:35:34.000000000 +0000 +++ httpcomponents-core-4.3.3/pom.xml 2014-10-18 11:42:56.000000000 +0000 @@ -33,7 +33,7 @@ 4.0.0 httpcomponents-core Apache HttpComponents Core - 4.3.2 + 4.3.3 Core components to build HTTP enabled services http://hc.apache.org/httpcomponents-core 2005 @@ -47,7 +47,7 @@ Apache License, Version 2.0 - LICENSE.txt + http://www.apache.org/licenses/LICENSE-2.0.txt repo @@ -58,9 +58,9 @@ - scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.3.2 - scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.3.2 - https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.3.2 + scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.3.3 + scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.3.3 + https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.3.3 @@ -71,6 +71,8 @@ + 1.5 + 1.5 false 4.9 @@ -298,6 +300,34 @@ ${api.comparison.version} + + org.apache.rat + apache-rat-plugin + 0.11 + + + verify + + check + + + + NOTICE.* + LICENSE.* + README.* + **/.* + .*/**/* + + + + + + + src/docbkx/resources/** + src/test/resources/*.truststore + + + diff -Nru httpcomponents-core-4.3.2/RELEASE_NOTES.txt httpcomponents-core-4.3.3/RELEASE_NOTES.txt --- httpcomponents-core-4.3.2/RELEASE_NOTES.txt 2014-02-12 20:35:26.000000000 +0000 +++ httpcomponents-core-4.3.3/RELEASE_NOTES.txt 2014-10-18 11:42:50.000000000 +0000 @@ -1,3 +1,35 @@ +Release 4.3.3 +------------------- + +This maintenance release fixes several bugs found since 4.3.2, mostly in the NIO transport +components. All users of HttpCore 4.3 are advised to upgrade. + +Changelog +------------------- + +* Make a connection exception throw a ConnectException instead of a SocketTimeoutException + to allow a FutureCallback handler to correctly distinguish between the two events. + Contributed by Asankha Perera + +* [HTTPASYNC-77] system resources are not correctly deallocated if I/O reactor is shut down + while still inactive (not started) + Contributed by Oleg Kalnichevski + +* [HTTPCORE-379] shut down non-blocking server side connection in case of an i/o or runtime error + to avoid an infinite loop in the i/o reactor trying to flush buffered output + Contributed by Dmitry Potapov + +* [HTTPCORE-376] AbstractNIOConnPool#requestCancelled() should not process pending requests + wnen being shut down. + Contributed by Dmitry Potapov + +* [HTTPASYNC-69]: async request handler is closed by HttpAsyncRequestExecutor#closed + if the underlying connection is found to be in an inconsistent state. + Contributed by Oleg Kalnichevski + + + + Release 4.3.2 -------------------