You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2010/04/23 21:11:57 UTC
svn commit: r937477 [2/9] - in
/httpcomponents/httpcore/trunk/httpcore-nio/src:
main/java/org/apache/http/impl/nio/
main/java/org/apache/http/impl/nio/codecs/
main/java/org/apache/http/impl/nio/reactor/
main/java/org/apache/http/impl/nio/ssl/ main/java...
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java Fri Apr 23 19:11:53 2010
@@ -42,8 +42,8 @@ import org.apache.http.util.CharArrayBuf
/**
* Default {@link NHttpMessageParser} implementation for {@link HttpRequest}s.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
@@ -52,11 +52,11 @@ import org.apache.http.util.CharArrayBuf
* @since 4.1
*/
public class DefaultHttpRequestParser extends AbstractMessageParser<HttpRequest> {
-
+
private final HttpRequestFactory requestFactory;
-
+
public DefaultHttpRequestParser(
- final SessionInputBuffer buffer,
+ final SessionInputBuffer buffer,
final LineParser parser,
final HttpRequestFactory requestFactory,
final HttpParams params) {
@@ -68,7 +68,7 @@ public class DefaultHttpRequestParser ex
}
@Override
- protected HttpRequest createMessage(final CharArrayBuffer buffer)
+ protected HttpRequest createMessage(final CharArrayBuffer buffer)
throws HttpException, ParseException {
ParserCursor cursor = new ParserCursor(0, buffer.length());
RequestLine requestLine = lineParser.parseRequestLine(buffer, cursor);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java Fri Apr 23 19:11:53 2010
@@ -48,7 +48,7 @@ public class DefaultHttpRequestWriter ex
final HttpParams params) {
super(buffer, formatter, params);
}
-
+
@Override
protected void writeHeadLine(final HttpRequest message) throws IOException {
CharArrayBuffer buffer = lineFormatter.formatRequestLine(
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java Fri Apr 23 19:11:53 2010
@@ -42,8 +42,8 @@ import org.apache.http.util.CharArrayBuf
/**
* Default {@link NHttpMessageParser} implementation for {@link HttpResponse}s.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
@@ -52,9 +52,9 @@ import org.apache.http.util.CharArrayBuf
* @since 4.1
*/
public class DefaultHttpResponseParser extends AbstractMessageParser<HttpResponse> {
-
+
private final HttpResponseFactory responseFactory;
-
+
public DefaultHttpResponseParser(
final SessionInputBuffer buffer,
final LineParser parser,
@@ -68,7 +68,7 @@ public class DefaultHttpResponseParser e
}
@Override
- protected HttpResponse createMessage(final CharArrayBuffer buffer)
+ protected HttpResponse createMessage(final CharArrayBuffer buffer)
throws HttpException, ParseException {
ParserCursor cursor = new ParserCursor(0, buffer.length());
StatusLine statusline = lineParser.parseStatusLine(buffer, cursor);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseWriter.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/DefaultHttpResponseWriter.java Fri Apr 23 19:11:53 2010
@@ -48,7 +48,7 @@ public class DefaultHttpResponseWriter e
final HttpParams params) {
super(buffer, formatter, params);
}
-
+
@Override
protected void writeHeadLine(final HttpResponse message) throws IOException {
CharArrayBuffer buffer = lineFormatter.formatStatusLine(
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestParser.java Fri Apr 23 19:11:53 2010
@@ -43,25 +43,25 @@ import org.apache.http.util.CharArrayBuf
/**
* Default {@link NHttpMessageParser} implementation for {@link HttpRequest}s.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
* </ul>
*
* @since 4.0
- *
+ *
* @deprecated use {@link DefaultHttpRequestParser}
*/
@SuppressWarnings("unchecked")
@Deprecated
public class HttpRequestParser extends AbstractMessageParser {
-
+
private final HttpRequestFactory requestFactory;
-
+
public HttpRequestParser(
- final SessionInputBuffer buffer,
+ final SessionInputBuffer buffer,
final LineParser parser,
final HttpRequestFactory requestFactory,
final HttpParams params) {
@@ -73,7 +73,7 @@ public class HttpRequestParser extends A
}
@Override
- protected HttpMessage createMessage(final CharArrayBuffer buffer)
+ protected HttpMessage createMessage(final CharArrayBuffer buffer)
throws HttpException, ParseException {
ParserCursor cursor = new ParserCursor(0, buffer.length());
RequestLine requestLine = lineParser.parseRequestLine(buffer, cursor);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpRequestWriter.java Fri Apr 23 19:11:53 2010
@@ -41,7 +41,7 @@ import org.apache.http.util.CharArrayBuf
* Default {@link NHttpMessageWriter} implementation for {@link HttpRequest}s.
*
* @since 4.0
- *
+ *
* @deprecated use {@link DefaultHttpRequestWriter}
*/
@SuppressWarnings("unchecked")
@@ -53,7 +53,7 @@ public class HttpRequestWriter extends A
final HttpParams params) {
super(buffer, formatter, params);
}
-
+
@Override
protected void writeHeadLine(final HttpMessage message)
throws IOException {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseParser.java Fri Apr 23 19:11:53 2010
@@ -43,23 +43,23 @@ import org.apache.http.util.CharArrayBuf
/**
* Default {@link NHttpMessageParser} implementation for {@link HttpResponse}s.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
* </ul>
*
* @since 4.0
- *
+ *
* @deprecated use {@link DefaultHttpResponseParser}
*/
@SuppressWarnings("unchecked")
@Deprecated
public class HttpResponseParser extends AbstractMessageParser {
-
+
private final HttpResponseFactory responseFactory;
-
+
public HttpResponseParser(
final SessionInputBuffer buffer,
final LineParser parser,
@@ -73,7 +73,7 @@ public class HttpResponseParser extends
}
@Override
- protected HttpMessage createMessage(final CharArrayBuffer buffer)
+ protected HttpMessage createMessage(final CharArrayBuffer buffer)
throws HttpException, ParseException {
ParserCursor cursor = new ParserCursor(0, buffer.length());
StatusLine statusline = lineParser.parseStatusLine(buffer, cursor);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/HttpResponseWriter.java Fri Apr 23 19:11:53 2010
@@ -41,7 +41,7 @@ import org.apache.http.util.CharArrayBuf
* Default {@link NHttpMessageWriter} implementation for {@link HttpResponse}s.
*
* @since 4.0
- *
+ *
* @deprecated use {@link DefaultHttpResponseWriter}
*/
@SuppressWarnings("unchecked")
@@ -53,7 +53,7 @@ public class HttpResponseWriter extends
final HttpParams params) {
super(buffer, formatter, params);
}
-
+
@Override
protected void writeHeadLine(final HttpMessage message)
throws IOException {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java Fri Apr 23 19:11:53 2010
@@ -37,27 +37,27 @@ import org.apache.http.nio.FileContentDe
import org.apache.http.nio.reactor.SessionInputBuffer;
/**
- * Content decoder that reads data without any transformation. The end of the
- * content entity is demarcated by closing the underlying connection
- * (EOF condition). Entities transferred using this input stream can be of
+ * Content decoder that reads data without any transformation. The end of the
+ * content entity is demarcated by closing the underlying connection
+ * (EOF condition). Entities transferred using this input stream can be of
* unlimited length.
* <p>
- * This decoder is optimized to transfer data directly from the underlying
- * I/O session's channel to a {@link FileChannel}, whenever
- * possible avoiding intermediate buffering in the session buffer.
+ * This decoder is optimized to transfer data directly from the underlying
+ * I/O session's channel to a {@link FileChannel}, whenever
+ * possible avoiding intermediate buffering in the session buffer.
*
* @since 4.0
*/
-public class IdentityDecoder extends AbstractContentDecoder
+public class IdentityDecoder extends AbstractContentDecoder
implements FileContentDecoder {
-
+
public IdentityDecoder(
- final ReadableByteChannel channel,
+ final ReadableByteChannel channel,
final SessionInputBuffer buffer,
final HttpTransportMetricsImpl metrics) {
super(channel, buffer, metrics);
}
-
+
/**
* Sets the completed status of this decoder. Normally this is not necessary
* (the decoder will automatically complete when the underlying channel
@@ -76,7 +76,7 @@ public class IdentityDecoder extends Abs
if (this.completed) {
return -1;
}
-
+
int bytesRead;
if (this.buffer.hasData()) {
bytesRead = this.buffer.read(dst);
@@ -91,19 +91,19 @@ public class IdentityDecoder extends Abs
}
return bytesRead;
}
-
+
public long transfer(
- final FileChannel dst,
- long position,
+ final FileChannel dst,
+ long position,
long count) throws IOException {
-
+
if (dst == null) {
return 0;
}
if (this.completed) {
return 0;
}
-
+
long bytesRead;
if (this.buffer.hasData()) {
dst.position(position);
@@ -111,10 +111,10 @@ public class IdentityDecoder extends Abs
} else {
if (this.channel.isOpen()) {
if(dst.size() < position)
- throw new IOException("FileChannel.size() [" + dst.size() +
- "] < position [" + position +
+ throw new IOException("FileChannel.size() [" + dst.size() +
+ "] < position [" + position +
"]. Please grow the file before writing.");
-
+
bytesRead = dst.transferFrom(this.channel, position, count);
if (bytesRead == 0) {
bytesRead = buffer.fill(this.channel);
@@ -140,5 +140,5 @@ public class IdentityDecoder extends Abs
buffer.append("]");
return buffer.toString();
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java Fri Apr 23 19:11:53 2010
@@ -37,22 +37,22 @@ import org.apache.http.nio.FileContentEn
import org.apache.http.nio.reactor.SessionOutputBuffer;
/**
- * Content encoder that writes data without any transformation. The end of
- * the content entity is demarcated by closing the underlying connection
- * (EOF condition). Entities transferred using this input stream can be of
- * unlimited length.
+ * Content encoder that writes data without any transformation. The end of
+ * the content entity is demarcated by closing the underlying connection
+ * (EOF condition). Entities transferred using this input stream can be of
+ * unlimited length.
* <p>
- * This decoder is optimized to transfer data directly from
- * a {@link FileChannel} to the underlying I/O session's channel whenever
- * possible avoiding intermediate buffering in the session buffer.
+ * This decoder is optimized to transfer data directly from
+ * a {@link FileChannel} to the underlying I/O session's channel whenever
+ * possible avoiding intermediate buffering in the session buffer.
*
* @since 4.0
*/
-public class IdentityEncoder extends AbstractContentEncoder
+public class IdentityEncoder extends AbstractContentEncoder
implements FileContentEncoder {
-
+
public IdentityEncoder(
- final WritableByteChannel channel,
+ final WritableByteChannel channel,
final SessionOutputBuffer buffer,
final HttpTransportMetricsImpl metrics) {
super(channel, buffer, metrics);
@@ -69,12 +69,12 @@ public class IdentityEncoder extends Abs
}
return bytesWritten;
}
-
+
public long transfer(
- final FileChannel src,
- long position,
+ final FileChannel src,
+ long position,
long count) throws IOException {
-
+
if (src == null) {
return 0;
}
@@ -84,8 +84,8 @@ public class IdentityEncoder extends Abs
this.metrics.incrementBytesTransferred(bytesWritten);
}
return bytesWritten;
- }
-
+ }
+
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
@@ -94,5 +94,5 @@ public class IdentityEncoder extends Abs
buffer.append("]");
return buffer.toString();
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java Fri Apr 23 19:11:53 2010
@@ -37,27 +37,27 @@ import org.apache.http.nio.FileContentDe
import org.apache.http.nio.reactor.SessionInputBuffer;
/**
- * Content decoder that cuts off after a defined number of bytes. This class
- * is used to receive content of HTTP messages where the end of the content
- * entity is determined by the value of the <code>Content-Length header</code>.
+ * Content decoder that cuts off after a defined number of bytes. This class
+ * is used to receive content of HTTP messages where the end of the content
+ * entity is determined by the value of the <code>Content-Length header</code>.
* Entities transferred using this stream can be maximum {@link Long#MAX_VALUE}
- * long.
+ * long.
* <p>
- * This decoder is optimized to transfer data directly from the underlying
- * I/O session's channel to a {@link FileChannel}, whenever
- * possible avoiding intermediate buffering in the session buffer.
- *
+ * This decoder is optimized to transfer data directly from the underlying
+ * I/O session's channel to a {@link FileChannel}, whenever
+ * possible avoiding intermediate buffering in the session buffer.
+ *
* @since 4.0
*/
-public class LengthDelimitedDecoder extends AbstractContentDecoder
+public class LengthDelimitedDecoder extends AbstractContentDecoder
implements FileContentDecoder {
-
+
private final long contentLength;
-
+
private long len;
public LengthDelimitedDecoder(
- final ReadableByteChannel channel,
+ final ReadableByteChannel channel,
final SessionInputBuffer buffer,
final HttpTransportMetricsImpl metrics,
long contentLength) {
@@ -76,7 +76,7 @@ public class LengthDelimitedDecoder exte
return -1;
}
int lenRemaining = (int) (this.contentLength - this.len);
-
+
int bytesRead;
if (this.buffer.hasData()) {
int maxLen = Math.min(lenRemaining, this.buffer.length());
@@ -109,21 +109,21 @@ public class LengthDelimitedDecoder exte
return bytesRead;
}
}
-
+
public long transfer(
- final FileChannel dst,
- long position,
+ final FileChannel dst,
+ long position,
long count) throws IOException {
-
+
if (dst == null) {
return 0;
}
if (this.completed) {
return -1;
}
-
+
int lenRemaining = (int) (this.contentLength - this.len);
-
+
long bytesRead;
if (this.buffer.hasData()) {
int maxLen = Math.min(lenRemaining, this.buffer.length());
@@ -135,10 +135,10 @@ public class LengthDelimitedDecoder exte
}
if (this.channel.isOpen()) {
if(dst.size() < position)
- throw new IOException("FileChannel.size() [" + dst.size() +
- "] < position [" + position +
+ throw new IOException("FileChannel.size() [" + dst.size() +
+ "] < position [" + position +
"]. Please grow the file before writing.");
-
+
bytesRead = dst.transferFrom(this.channel, position, count);
} else {
bytesRead = -1;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java Fri Apr 23 19:11:53 2010
@@ -37,34 +37,34 @@ import org.apache.http.nio.FileContentEn
import org.apache.http.nio.reactor.SessionOutputBuffer;
/**
- * Content encoder that cuts off after a defined number of bytes. This class
- * is used to send content of HTTP messages where the end of the content entity
- * is determined by the value of the <code>Content-Length header</code>.
+ * Content encoder that cuts off after a defined number of bytes. This class
+ * is used to send content of HTTP messages where the end of the content entity
+ * is determined by the value of the <code>Content-Length header</code>.
* Entities transferred using this stream can be maximum {@link Long#MAX_VALUE}
- * long.
+ * long.
* <p>
- * This decoder is optimized to transfer data directly from
- * a {@link FileChannel} to the underlying I/O session's channel whenever
- * possible avoiding intermediate buffering in the session buffer.
- *
+ * This decoder is optimized to transfer data directly from
+ * a {@link FileChannel} to the underlying I/O session's channel whenever
+ * possible avoiding intermediate buffering in the session buffer.
+ *
* @since 4.0
*/
-public class LengthDelimitedEncoder extends AbstractContentEncoder
+public class LengthDelimitedEncoder extends AbstractContentEncoder
implements FileContentEncoder {
-
+
private final long contentLength;
-
+
private long len;
public LengthDelimitedEncoder(
- final WritableByteChannel channel,
+ final WritableByteChannel channel,
final SessionOutputBuffer buffer,
final HttpTransportMetricsImpl metrics,
long contentLength) {
super(channel, buffer, metrics);
if (contentLength < 0) {
throw new IllegalArgumentException("Content length may not be negative");
- }
+ }
this.contentLength = contentLength;
this.len = 0;
}
@@ -97,16 +97,16 @@ public class LengthDelimitedEncoder exte
}
public long transfer(
- final FileChannel src,
- long position,
+ final FileChannel src,
+ long position,
long count) throws IOException {
-
+
if (src == null) {
return 0;
}
assertNotCompleted();
int lenRemaining = (int) (this.contentLength - this.len);
-
+
long bytesWritten;
if (count > lenRemaining) {
count = lenRemaining;
@@ -121,7 +121,7 @@ public class LengthDelimitedEncoder exte
}
return bytesWritten;
}
-
+
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
@@ -134,5 +134,5 @@ public class LengthDelimitedEncoder exte
buffer.append("]");
return buffer.toString();
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java Fri Apr 23 19:11:53 2010
@@ -48,7 +48,7 @@ import org.apache.http.nio.reactor.IORea
import org.apache.http.nio.reactor.IOSession;
/**
- * Generic implementation of {@link IOReactor} that can used as a subclass
+ * Generic implementation of {@link IOReactor} that can used as a subclass
* for more specialized I/O reactors. It is based on a single {@link Selector}
* instance.
*
@@ -57,7 +57,7 @@ import org.apache.http.nio.reactor.IOSes
public abstract class AbstractIOReactor implements IOReactor {
private volatile IOReactorStatus status;
-
+
private final Object statusMutex;
private final long selectTimeout;
private final boolean interestOpsQueueing;
@@ -69,22 +69,22 @@ public abstract class AbstractIOReactor
/**
* Creates new AbstractIOReactor instance.
- *
+ *
* @param selectTimeout the select timeout.
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
public AbstractIOReactor(long selectTimeout) throws IOReactorException {
this(selectTimeout, false);
}
-
+
/**
* Creates new AbstractIOReactor instance.
- *
+ *
* @param selectTimeout the select timeout.
* @param interestOpsQueueing Ops queueing flag.
- *
- * @throws IOReactorException in case if a non-recoverable I/O error.
- *
+ *
+ * @throws IOReactorException in case if a non-recoverable I/O error.
+ *
* @since 4.1
*/
public AbstractIOReactor(long selectTimeout, boolean interestOpsQueueing) throws IOReactorException {
@@ -111,16 +111,16 @@ public abstract class AbstractIOReactor
* Triggered when the key signals {@link SelectionKey#OP_ACCEPT} readiness.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param key the selection key.
*/
protected abstract void acceptable(SelectionKey key);
-
+
/**
* Triggered when the key signals {@link SelectionKey#OP_CONNECT} readiness.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param key the selection key.
*/
protected abstract void connectable(SelectionKey key);
@@ -129,7 +129,7 @@ public abstract class AbstractIOReactor
* Triggered when the key signals {@link SelectionKey#OP_READ} readiness.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param key the selection key.
*/
protected abstract void readable(SelectionKey key);
@@ -138,69 +138,69 @@ public abstract class AbstractIOReactor
* Triggered when the key signals {@link SelectionKey#OP_WRITE} readiness.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param key the selection key.
*/
protected abstract void writable(SelectionKey key);
-
+
/**
- * Triggered to verify whether the I/O session associated with the
+ * Triggered to verify whether the I/O session associated with the
* given selection key has not timed out.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param key the selection key.
* @param now current time as long value.
*/
protected abstract void timeoutCheck(SelectionKey key, long now);
/**
- * Triggered to validate keys currently registered with the selector. This
+ * Triggered to validate keys currently registered with the selector. This
* method is called after each I/O select loop.
* <p>
- * Super-classes can implement this method to run validity checks on
+ * Super-classes can implement this method to run validity checks on
* active sessions and include additional processing that needs to be
* executed after each I/O select loop.
- *
+ *
* @param keys all selection keys registered with the selector.
*/
protected abstract void validate(Set<SelectionKey> keys);
-
+
/**
* Triggered when new session has been created.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param key the selection key.
* @param session new I/O session.
*/
protected abstract void sessionCreated(SelectionKey key, IOSession session);
-
+
/**
* Triggered when a session has been closed.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param session closed I/O session.
*/
protected abstract void sessionClosed(IOSession session);
-
+
/**
* Obtains {@link IOSession} instance associated with the given selection
* key.
- *
+ *
* @param key the selection key.
* @return I/O session.
*/
protected abstract IOSession getSession(SelectionKey key);
-
+
public IOReactorStatus getStatus() {
return this.status;
}
/**
* Returns <code>true</code> if interest Ops queueing is enabled, <code>false</code> otherwise.
- *
+ *
* @since 4.1
*/
public boolean getInterestOpsQueueing() {
@@ -210,7 +210,7 @@ public abstract class AbstractIOReactor
/**
* Adds new channel entry. The channel will be asynchronously registered
* with the selector.
- *
+ *
* @param channelEntry the channel entry.
*/
public void addChannel(final ChannelEntry channelEntry) {
@@ -220,17 +220,17 @@ public abstract class AbstractIOReactor
this.newChannels.add(channelEntry);
this.selector.wakeup();
}
-
+
/**
- * Activates the I/O reactor. The I/O reactor will start reacting to
+ * Activates the I/O reactor. The I/O reactor will start reacting to
* I/O events and triggering notification methods.
* <p>
- * This method will enter the infinite I/O select loop on
+ * This method will enter the infinite I/O select loop on
* the {@link Selector} instance associated with this I/O reactor.
* <p>
* The method will remain blocked unto the I/O reactor is shut down or the
- * execution thread is interrupted.
- *
+ * execution thread is interrupted.
+ *
* @see #acceptable(SelectionKey)
* @see #connectable(SelectionKey)
* @see #readable(SelectionKey)
@@ -239,16 +239,16 @@ public abstract class AbstractIOReactor
* @see #validate(Set)
* @see #sessionCreated(SelectionKey, IOSession)
* @see #sessionClosed(IOSession)
- *
- * @throws InterruptedIOException if the dispatch thread is interrupted.
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ *
+ * @throws InterruptedIOException if the dispatch thread is interrupted.
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
protected void execute() throws InterruptedIOException, IOReactorException {
this.status = IOReactorStatus.ACTIVE;
try {
for (;;) {
-
+
int readyCount;
try {
readyCount = this.selector.select(this.selectTimeout);
@@ -257,7 +257,7 @@ public abstract class AbstractIOReactor
} catch (IOException ex) {
throw new IOReactorException("Unexpected selector failure", ex);
}
-
+
if (this.status == IOReactorStatus.SHUT_DOWN) {
// Hard shut down. Exit select loop immediately
break;
@@ -269,15 +269,15 @@ public abstract class AbstractIOReactor
closeSessions();
closeNewChannels();
}
-
- // Process selected I/O events
+
+ // Process selected I/O events
if (readyCount > 0) {
processEvents(this.selector.selectedKeys());
}
-
+
// Validate active channels
validate(this.selector.keys());
-
+
// Process closed sessions
processClosedSessions();
@@ -285,9 +285,9 @@ public abstract class AbstractIOReactor
if (this.status == IOReactorStatus.ACTIVE) {
processNewChannels();
}
-
+
// Exit select loop if graceful shutdown has been completed
- if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0
+ if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0
&& this.sessions.isEmpty()) {
break;
}
@@ -296,9 +296,9 @@ public abstract class AbstractIOReactor
// process all pending interestOps() operations
processPendingInterestOps();
}
-
+
}
-
+
} catch (ClosedSelectorException ex) {
} finally {
hardShutdown();
@@ -307,20 +307,20 @@ public abstract class AbstractIOReactor
}
}
}
-
+
private void processEvents(final Set<SelectionKey> selectedKeys) {
for (Iterator<SelectionKey> it = selectedKeys.iterator(); it.hasNext(); ) {
-
+
SelectionKey key = it.next();
processEvent(key);
-
+
}
selectedKeys.clear();
}
-
+
/**
* Processes new event on the given selection key.
- *
+ *
* @param key the selection key that triggered an event.
*/
protected void processEvent(final SelectionKey key) {
@@ -339,14 +339,14 @@ public abstract class AbstractIOReactor
}
} catch (CancelledKeyException ex) {
IOSession session = getSession(key);
- queueClosedSession(session);
+ queueClosedSession(session);
key.attach(null);
}
}
/**
* Queues the given I/O session to be processed asynchronously as closed.
- *
+ *
* @param session the closed I/O session.
*/
protected void queueClosedSession(final IOSession session) {
@@ -354,11 +354,11 @@ public abstract class AbstractIOReactor
this.closedSessions.add(session);
}
}
-
+
private void processNewChannels() throws IOReactorException {
ChannelEntry entry;
while ((entry = this.newChannels.poll()) != null) {
-
+
SocketChannel channel;
SelectionKey key;
try {
@@ -382,9 +382,9 @@ public abstract class AbstractIOReactor
public void sessionClosed(IOSession session) {
queueClosedSession(session);
}
-
+
};
-
+
InterestOpsCallback interestOpsCallback = null;
if (this.interestOpsQueueing) {
interestOpsCallback = new InterestOpsCallback() {
@@ -392,12 +392,12 @@ public abstract class AbstractIOReactor
public void addInterestOps(InterestOpEntry entry) {
queueInterestOps(entry);
}
-
+
};
}
-
+
IOSession session = new IOSessionImpl(key, interestOpsCallback, sessionClosedCallback);
-
+
int timeout = 0;
try {
timeout = channel.socket().getSoTimeout();
@@ -406,7 +406,7 @@ public abstract class AbstractIOReactor
// as the protocol layer is expected to overwrite
// this value anyways
}
-
+
session.setAttribute(IOSession.ATTACHMENT_KEY, entry.getAttachment());
session.setSocketTimeout(timeout);
this.sessions.add(session);
@@ -457,12 +457,12 @@ public abstract class AbstractIOReactor
}
}
- /**
+ /**
* Adds an {@link InterestOpEntry} to the interest ops queue for this instance.
- *
- * @return <code>true</code> if the operation could be performed successfully,
+ *
+ * @return <code>true</code> if the operation could be performed successfully,
* <code>false</code> otherwise.
- *
+ *
* @since 4.1
*/
protected boolean queueInterestOps(final InterestOpEntry entry) {
@@ -481,7 +481,7 @@ public abstract class AbstractIOReactor
return true;
}
-
+
/**
* Closes out all I/O sessions maintained by this I/O reactor.
*/
@@ -493,9 +493,9 @@ public abstract class AbstractIOReactor
}
}
}
-
+
/**
- * Closes out all new channels pending registration with the selector of
+ * Closes out all new channels pending registration with the selector of
* this I/O reactor.
* @throws IOReactorException - not thrown currently
*/
@@ -513,9 +513,9 @@ public abstract class AbstractIOReactor
}
}
}
-
+
/**
- * Closes out all active channels registered with the selector of
+ * Closes out all active channels registered with the selector of
* this I/O reactor.
* @throws IOReactorException - not thrown currently
*/
@@ -533,7 +533,7 @@ public abstract class AbstractIOReactor
} catch (IOException ignore) {
}
}
-
+
/**
* Attempts graceful shutdown of this I/O reactor.
*/
@@ -547,7 +547,7 @@ public abstract class AbstractIOReactor
}
this.selector.wakeup();
}
-
+
/**
* Attempts force-shutdown of this I/O reactor.
*/
@@ -559,16 +559,16 @@ public abstract class AbstractIOReactor
}
this.status = IOReactorStatus.SHUT_DOWN;
}
-
+
closeNewChannels();
closeActiveChannels();
processClosedSessions();
}
-
+
/**
- * Blocks for the given period of time in milliseconds awaiting
+ * Blocks for the given period of time in milliseconds awaiting
* the completion of the reactor shutdown.
- *
+ *
* @param timeout the maximum wait time.
* @throws InterruptedException if interrupted.
*/
@@ -587,7 +587,7 @@ public abstract class AbstractIOReactor
}
}
}
-
+
public void shutdown(long gracePeriod) throws IOReactorException {
if (this.status != IOReactorStatus.INACTIVE) {
gracefulShutdown();
@@ -600,7 +600,7 @@ public abstract class AbstractIOReactor
hardShutdown();
}
}
-
+
public void shutdown() throws IOReactorException {
shutdown(1000);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java Fri Apr 23 19:11:53 2010
@@ -53,45 +53,45 @@ import org.apache.http.params.HttpConnec
import org.apache.http.params.HttpParams;
/**
- * Generic implementation of {@link IOReactor} that can run multiple
- * {@link BaseIOReactor} instance in separate worker threads and distribute
+ * Generic implementation of {@link IOReactor} that can run multiple
+ * {@link BaseIOReactor} instance in separate worker threads and distribute
* newly created I/O session equally across those I/O reactors for a more
- * optimal resource utilization and a better I/O performance. Usually it is
+ * optimal resource utilization and a better I/O performance. Usually it is
* recommended to have one worker I/O reactor per physical CPU core.
* <p>
* <strong>Important note about exception handling</strong>
* <p>
- * Protocol specific exceptions as well as those I/O exceptions thrown in the
- * course of interaction with the session's channel are to be expected are to be
- * dealt with by specific protocol handlers. These exceptions may result in
- * termination of an individual session but should not affect the I/O reactor
- * and all other active sessions. There are situations, however, when the I/O
- * reactor itself encounters an internal problem such as an I/O exception in
- * the underlying NIO classes or an unhandled runtime exception. Those types of
- * exceptions are usually fatal and will cause the I/O reactor to shut down
+ * Protocol specific exceptions as well as those I/O exceptions thrown in the
+ * course of interaction with the session's channel are to be expected are to be
+ * dealt with by specific protocol handlers. These exceptions may result in
+ * termination of an individual session but should not affect the I/O reactor
+ * and all other active sessions. There are situations, however, when the I/O
+ * reactor itself encounters an internal problem such as an I/O exception in
+ * the underlying NIO classes or an unhandled runtime exception. Those types of
+ * exceptions are usually fatal and will cause the I/O reactor to shut down
* automatically.
* <p>
- * There is a possibility to override this behavior and prevent I/O reactors
- * from shutting down automatically in case of a runtime exception or an I/O
- * exception in internal classes. This can be accomplished by providing a custom
- * implementation of the {@link IOReactorExceptionHandler} interface.
+ * There is a possibility to override this behavior and prevent I/O reactors
+ * from shutting down automatically in case of a runtime exception or an I/O
+ * exception in internal classes. This can be accomplished by providing a custom
+ * implementation of the {@link IOReactorExceptionHandler} interface.
* <p>
- * If an I/O reactor is unable to automatically recover from an I/O or a runtime
- * exception it will enter the shutdown mode. First off, it cancel all pending
- * new session requests. Then it will attempt to close all active I/O sessions
- * gracefully giving them some time to flush pending output data and terminate
- * cleanly. Lastly, it will forcibly shut down those I/O sessions that still
- * remain active after the grace period. This is a fairly complex process, where
- * many things can fail at the same time and many different exceptions can be
- * thrown in the course of the shutdown process. The I/O reactor will record all
- * exceptions thrown during the shutdown process, including the original one
- * that actually caused the shutdown in the first place, in an audit log. One
+ * If an I/O reactor is unable to automatically recover from an I/O or a runtime
+ * exception it will enter the shutdown mode. First off, it cancel all pending
+ * new session requests. Then it will attempt to close all active I/O sessions
+ * gracefully giving them some time to flush pending output data and terminate
+ * cleanly. Lastly, it will forcibly shut down those I/O sessions that still
+ * remain active after the grace period. This is a fairly complex process, where
+ * many things can fail at the same time and many different exceptions can be
+ * thrown in the course of the shutdown process. The I/O reactor will record all
+ * exceptions thrown during the shutdown process, including the original one
+ * that actually caused the shutdown in the first place, in an audit log. One
* can obtain the audit log using {@link #getAuditLog()}, examine exceptions
- * thrown by the I/O reactor prior and in the course of the reactor shutdown
+ * thrown by the I/O reactor prior and in the course of the reactor shutdown
* and decide whether it is safe to restart the I/O reactor.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
@@ -106,7 +106,7 @@ import org.apache.http.params.HttpParams
public abstract class AbstractMultiworkerIOReactor implements IOReactor {
protected volatile IOReactorStatus status;
-
+
protected final HttpParams params;
protected final Selector selector;
protected final long selectTimeout;
@@ -118,23 +118,23 @@ public abstract class AbstractMultiworke
private final Worker[] workers;
private final Thread[] threads;
private final Object statusLock;
-
+
protected IOReactorExceptionHandler exceptionHandler;
protected List<ExceptionEvent> auditLog;
-
+
private int currentWorker = 0;
/**
* Creates an instance of AbstractMultiworkerIOReactor.
*
- * @param workerCount number of worker I/O reactors.
- * @param threadFactory the factory to create threads.
+ * @param workerCount number of worker I/O reactors.
+ * @param threadFactory the factory to create threads.
* Can be <code>null</code>.
* @param params HTTP parameters.
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
public AbstractMultiworkerIOReactor(
- int workerCount,
+ int workerCount,
final ThreadFactory threadFactory,
final HttpParams params) throws IOReactorException {
super();
@@ -168,11 +168,11 @@ public abstract class AbstractMultiworke
public IOReactorStatus getStatus() {
return this.status;
}
-
+
/**
- * Returns the audit log containing exceptions thrown by the I/O reactor
+ * Returns the audit log containing exceptions thrown by the I/O reactor
* prior and in the course of the reactor shutdown.
- *
+ *
* @return audit log.
*/
public synchronized List<ExceptionEvent> getAuditLog() {
@@ -186,9 +186,9 @@ public abstract class AbstractMultiworke
/**
* Adds the given {@link Throwable} object with the given time stamp
* to the audit log.
- *
+ *
* @param ex the exception thrown by the I/O reactor.
- * @param timestamp the time stamp of the exception. Can be
+ * @param timestamp the time stamp of the exception. Can be
* <code>null</code> in which case the current date / time will be used.
*/
protected synchronized void addExceptionEvent(final Throwable ex, Date timestamp) {
@@ -203,10 +203,10 @@ public abstract class AbstractMultiworke
}
this.auditLog.add(new ExceptionEvent(ex, timestamp));
}
-
+
/**
* Adds the given {@link Throwable} object to the audit log.
- *
+ *
* @param ex the exception thrown by the I/O reactor.
*/
protected void addExceptionEvent(final Throwable ex) {
@@ -215,53 +215,53 @@ public abstract class AbstractMultiworke
/**
* Sets exception handler for this I/O reactor.
- *
- * @param exceptionHandler the exception handler.
+ *
+ * @param exceptionHandler the exception handler.
*/
public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
this.exceptionHandler = exceptionHandler;
}
-
+
/**
* Triggered to process I/O events registered by the main {@link Selector}.
* <p>
* Super-classes can implement this method to react to the event.
- *
+ *
* @param count event count.
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
protected abstract void processEvents(int count) throws IOReactorException;
-
+
/**
* Triggered to cancel pending session requests.
* <p>
* Super-classes can implement this method to react to the event.
- *
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ *
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
protected abstract void cancelRequests() throws IOReactorException;
-
+
/**
- * Activates the main I/O reactor as well as all worker I/O reactors.
- * The I/O main reactor will start reacting to I/O events and triggering
- * notification methods. The worker I/O reactor in their turn will start
- * reacting to I/O events and dispatch I/O event notifications to the given
+ * Activates the main I/O reactor as well as all worker I/O reactors.
+ * The I/O main reactor will start reacting to I/O events and triggering
+ * notification methods. The worker I/O reactor in their turn will start
+ * reacting to I/O events and dispatch I/O event notifications to the given
* {@link IOEventDispatch} interface.
* <p>
- * This method will enter the infinite I/O select loop on
- * the {@link Selector} instance associated with this I/O reactor and used
+ * This method will enter the infinite I/O select loop on
+ * the {@link Selector} instance associated with this I/O reactor and used
* to manage creation of new I/O channels. Once a new I/O channel has been
- * created the processing of I/O events on that channel will be delegated
+ * created the processing of I/O events on that channel will be delegated
* to one of the worker I/O reactors.
* <p>
* The method will remain blocked unto the I/O reactor is shut down or the
- * execution thread is interrupted.
- *
+ * execution thread is interrupted.
+ *
* @see #processEvents(int)
* @see #cancelRequests()
- *
- * @throws InterruptedIOException if the dispatch thread is interrupted.
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ *
+ * @throws InterruptedIOException if the dispatch thread is interrupted.
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
public void execute(
final IOEventDispatch eventDispatch) throws InterruptedIOException, IOReactorException {
@@ -298,7 +298,7 @@ public abstract class AbstractMultiworke
}
this.threads[i].start();
}
-
+
for (;;) {
int readyCount;
try {
@@ -308,7 +308,7 @@ public abstract class AbstractMultiworke
} catch (IOException ex) {
throw new IOReactorException("Unexpected selector failure", ex);
}
-
+
if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0) {
break;
}
@@ -346,11 +346,11 @@ public abstract class AbstractMultiworke
/**
* Activates the shutdown sequence for this reactor. This method will cancel
- * all pending session requests, close out all active I/O channels,
+ * all pending session requests, close out all active I/O channels,
* make an attempt to terminate all worker I/O reactors gracefully,
* and finally force-terminate those I/O reactors that failed to
* terminate after the specified grace period.
- *
+ *
* @throws InterruptedIOException if the shutdown sequence has been
* interrupted.
*/
@@ -362,14 +362,14 @@ public abstract class AbstractMultiworke
this.status = IOReactorStatus.SHUTTING_DOWN;
}
try {
- cancelRequests();
+ cancelRequests();
} catch (IOReactorException ex) {
if (ex.getCause() != null) {
addExceptionEvent(ex.getCause());
}
}
this.selector.wakeup();
-
+
// Close out all channels
if (this.selector.isOpen()) {
Set<SelectionKey> keys = this.selector.keys();
@@ -399,7 +399,7 @@ public abstract class AbstractMultiworke
}
long gracePeriod = NIOReactorParams.getGracePeriod(this.params);
-
+
try {
// Force shut down I/O dispatchers if they fail to terminate
// in time
@@ -432,7 +432,7 @@ public abstract class AbstractMultiworke
/**
* Assigns the given channel entry to one of the worker I/O reactors.
- *
+ *
* @param entry the channel entry.
*/
protected void addChannel(final ChannelEntry entry) {
@@ -440,10 +440,10 @@ public abstract class AbstractMultiworke
int i = Math.abs(this.currentWorker++ % this.workerCount);
this.dispatchers[i].addChannel(entry);
}
-
+
/**
* Registers the given channel with the main {@link Selector}.
- *
+ *
* @param channel the channel.
* @param ops interest ops.
* @return selection key.
@@ -456,7 +456,7 @@ public abstract class AbstractMultiworke
/**
* Prepares the given {@link Socket} by resetting some of its properties.
- *
+ *
* @param socket the socket
* @throws IOException in case of an I/O error.
*/
@@ -470,11 +470,11 @@ public abstract class AbstractMultiworke
}
/**
- * Blocks for the given period of time in milliseconds awaiting
- * the completion of the reactor shutdown. If the value of
+ * Blocks for the given period of time in milliseconds awaiting
+ * the completion of the reactor shutdown. If the value of
* <code>timeout</code> is set to <code>0</code> this method blocks
- * indefinitely.
- *
+ * indefinitely.
+ *
* @param timeout the maximum wait time.
* @throws InterruptedException if interrupted.
*/
@@ -521,15 +521,15 @@ public abstract class AbstractMultiworke
final BaseIOReactor dispatcher;
final IOEventDispatch eventDispatch;
-
+
private volatile Exception exception;
-
+
public Worker(final BaseIOReactor dispatcher, final IOEventDispatch eventDispatch) {
super();
this.dispatcher = dispatcher;
this.eventDispatch = eventDispatch;
}
-
+
public void run() {
try {
this.dispatcher.execute(this.eventDispatch);
@@ -537,7 +537,7 @@ public abstract class AbstractMultiworke
this.exception = ex;
}
}
-
+
public Exception getException() {
return this.exception;
}
@@ -547,11 +547,11 @@ public abstract class AbstractMultiworke
static class DefaultThreadFactory implements ThreadFactory {
private static volatile int COUNT = 0;
-
+
public Thread newThread(final Runnable r) {
return new Thread(r, "I/O dispatcher " + (++COUNT));
}
-
+
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java Fri Apr 23 19:11:53 2010
@@ -44,7 +44,7 @@ import org.apache.http.nio.reactor.IOSes
/**
* Default implementation of {@link AbstractIOReactor} that serves as a base
* for more advanced {@link IOReactor} implementations. This class adds
- * support for the I/O event dispatching using {@link IOEventDispatch},
+ * support for the I/O event dispatching using {@link IOEventDispatch},
* management of buffering sessions, and session timeout handling.
*
* @since 4.0
@@ -61,23 +61,23 @@ public class BaseIOReactor extends Abstr
/**
* Creates new BaseIOReactor instance.
- *
+ *
* @param selectTimeout the select timeout.
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
public BaseIOReactor(long selectTimeout) throws IOReactorException {
this(selectTimeout, false);
}
-
+
/**
* Creates new BaseIOReactor instance.
- *
+ *
* @param selectTimeout the select timeout.
* @param interestOpsQueueing Ops queueing flag.
- *
- * @throws IOReactorException in case if a non-recoverable I/O error.
- *
- * @since 4.1
+ *
+ * @throws IOReactorException in case if a non-recoverable I/O error.
+ *
+ * @since 4.1
*/
public BaseIOReactor(
long selectTimeout, boolean interestOpsQueueing) throws IOReactorException {
@@ -89,11 +89,11 @@ public class BaseIOReactor extends Abstr
/**
* Activates the I/O reactor. The I/O reactor will start reacting to I/O
- * events and dispatch I/O event notifications to the given
+ * events and dispatch I/O event notifications to the given
* {@link IOEventDispatch}.
- *
- * @throws InterruptedIOException if the dispatch thread is interrupted.
- * @throws IOReactorException in case if a non-recoverable I/O error.
+ *
+ * @throws InterruptedIOException if the dispatch thread is interrupted.
+ * @throws IOReactorException in case if a non-recoverable I/O error.
*/
public void execute(
final IOEventDispatch eventDispatch) throws InterruptedIOException, IOReactorException {
@@ -106,18 +106,18 @@ public class BaseIOReactor extends Abstr
/**
* Sets exception handler for this I/O reactor.
- *
- * @param exceptionHandler the exception handler.
+ *
+ * @param exceptionHandler the exception handler.
*/
public void setExceptionHandler(IOReactorExceptionHandler exceptionHandler) {
this.exceptionHandler = exceptionHandler;
}
/**
- * Handles the given {@link RuntimeException}. This method delegates
- * handling of the exception to the {@link IOReactorExceptionHandler},
+ * Handles the given {@link RuntimeException}. This method delegates
+ * handling of the exception to the {@link IOReactorExceptionHandler},
* if available.
- *
+ *
* @param ex the runtime exception.
*/
protected void handleRuntimeException(final RuntimeException ex) {
@@ -127,7 +127,7 @@ public class BaseIOReactor extends Abstr
}
/**
- * This I/O reactor implementation does not react to the
+ * This I/O reactor implementation does not react to the
* {@link SelectionKey#OP_ACCEPT} event.
* <p>
* Super-classes can override this method to react to the event.
@@ -137,7 +137,7 @@ public class BaseIOReactor extends Abstr
}
/**
- * This I/O reactor implementation does not react to the
+ * This I/O reactor implementation does not react to the
* {@link SelectionKey#OP_CONNECT} event.
* <p>
* Super-classes can override this method to react to the event.
@@ -148,7 +148,7 @@ public class BaseIOReactor extends Abstr
/**
* Processes {@link SelectionKey#OP_READ} event on the given selection key.
- * This method dispatches the event notification to the
+ * This method dispatches the event notification to the
* {@link IOEventDispatch#inputReady(IOSession)} method.
*/
@Override
@@ -172,7 +172,7 @@ public class BaseIOReactor extends Abstr
/**
* Processes {@link SelectionKey#OP_WRITE} event on the given selection key.
- * This method dispatches the event notification to the
+ * This method dispatches the event notification to the
* {@link IOEventDispatch#outputReady(IOSession)} method.
*/
@Override
@@ -194,11 +194,11 @@ public class BaseIOReactor extends Abstr
/**
* Verifies whether any of the sessions associated with the given selection
* keys timed out by invoking the {@link #timeoutCheck(SelectionKey, long)}
- * method.
+ * method.
* <p>
- * This method will also invoke the
- * {@link IOEventDispatch#inputReady(IOSession)} method on all sessions
- * that have buffered input data.
+ * This method will also invoke the
+ * {@link IOEventDispatch#inputReady(IOSession)} method on all sessions
+ * that have buffered input data.
*/
@Override
protected void validate(final Set<SelectionKey> keys) {
@@ -219,7 +219,7 @@ public class BaseIOReactor extends Abstr
it.remove();
continue;
}
-
+
int ops = 0;
try {
ops = session.getEventMask();
@@ -228,7 +228,7 @@ public class BaseIOReactor extends Abstr
queueClosedSession(session);
continue;
}
-
+
if ((ops & EventMask.READ) > 0) {
try {
this.eventDispatch.inputReady(session);
@@ -247,7 +247,7 @@ public class BaseIOReactor extends Abstr
}
/**
- * Performs timeout check for the I/O session associated with the given
+ * Performs timeout check for the I/O session associated with the given
* selection key.
*/
@Override
@@ -273,7 +273,7 @@ public class BaseIOReactor extends Abstr
}
/**
- * Processes newly created I/O session. This method dispatches the event
+ * Processes newly created I/O session. This method dispatches the event
* notification to the {@link IOEventDispatch#connected(IOSession)} method.
*/
@Override
@@ -302,8 +302,8 @@ public class BaseIOReactor extends Abstr
}
/**
- * Processes closed I/O session. This method dispatches the event
- * notification to the {@link IOEventDispatch#disconnected(IOSession)}
+ * Processes closed I/O session. This method dispatches the event
+ * notification to the {@link IOEventDispatch#disconnected(IOSession)}
* method.
*/
@Override
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ChannelEntry.java Fri Apr 23 19:11:53 2010
@@ -40,10 +40,10 @@ public class ChannelEntry {
private final SocketChannel channel;
private final SessionRequestImpl sessionRequest;
-
+
/**
* Creates new ChannelEntry.
- *
+ *
* @param channel the channel
* @param sessionRequest original session request. Can be <code>null</code>
* if the channel represents an incoming server-side connection.
@@ -59,7 +59,7 @@ public class ChannelEntry {
/**
* Creates new ChannelEntry.
- *
+ *
* @param channel the channel.
*/
public ChannelEntry(final SocketChannel channel) {
@@ -68,11 +68,11 @@ public class ChannelEntry {
/**
* Returns the original session request, if available. If the channel
- * entry represents an incoming server-side connection, returns
+ * entry represents an incoming server-side connection, returns
* <code>null</code>.
- *
+ *
* @return the original session request, if client-side channel,
- * <code>null</code> otherwise.
+ * <code>null</code> otherwise.
*/
public SessionRequestImpl getSessionRequest() {
return this.sessionRequest;
@@ -80,9 +80,9 @@ public class ChannelEntry {
/**
* Returns the original session request attachment, if available.
- *
+ *
* @return the original session request attachment, if available,
- * <code>null</code> otherwise.
+ * <code>null</code> otherwise.
*/
public Object getAttachment() {
if (this.sessionRequest != null) {
@@ -94,11 +94,11 @@ public class ChannelEntry {
/**
* Returns the channel.
- *
+ *
* @return the channel.
*/
public SocketChannel getChannel() {
return this.channel;
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java Fri Apr 23 19:11:53 2010
@@ -50,12 +50,12 @@ import org.apache.http.params.HttpConnec
import org.apache.http.params.HttpParams;
/**
- * Default implementation of {@link ConnectingIOReactor}. This class extends
+ * Default implementation of {@link ConnectingIOReactor}. This class extends
* {@link AbstractMultiworkerIOReactor} with capability to connect to remote
* hosts.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
@@ -68,15 +68,15 @@ import org.apache.http.params.HttpParams
*
* @since 4.0
*/
-public class DefaultConnectingIOReactor extends AbstractMultiworkerIOReactor
+public class DefaultConnectingIOReactor extends AbstractMultiworkerIOReactor
implements ConnectingIOReactor {
private final Queue<SessionRequestImpl> requestQueue;
-
+
private long lastTimeoutCheck;
-
+
public DefaultConnectingIOReactor(
- int workerCount,
+ int workerCount,
final ThreadFactory threadFactory,
final HttpParams params) throws IOReactorException {
super(workerCount, threadFactory, params);
@@ -85,11 +85,11 @@ public class DefaultConnectingIOReactor
}
public DefaultConnectingIOReactor(
- int workerCount,
+ int workerCount,
final HttpParams params) throws IOReactorException {
this(workerCount, null, params);
}
-
+
@Override
protected void cancelRequests() throws IOReactorException {
SessionRequestImpl request;
@@ -101,18 +101,18 @@ public class DefaultConnectingIOReactor
@Override
protected void processEvents(int readyCount) throws IOReactorException {
processSessionRequests();
-
+
if (readyCount > 0) {
Set<SelectionKey> selectedKeys = this.selector.selectedKeys();
for (Iterator<SelectionKey> it = selectedKeys.iterator(); it.hasNext(); ) {
-
+
SelectionKey key = it.next();
processEvent(key);
-
+
}
selectedKeys.clear();
}
-
+
long currentTime = System.currentTimeMillis();
if ((currentTime - this.lastTimeoutCheck) >= this.selectTimeout) {
this.lastTimeoutCheck = currentTime;
@@ -123,14 +123,14 @@ public class DefaultConnectingIOReactor
private void processEvent(final SelectionKey key) {
try {
-
+
if (key.isConnectable()) {
SocketChannel channel = (SocketChannel) key.channel();
// Get request handle
SessionRequestHandle requestHandle = (SessionRequestHandle) key.attachment();
SessionRequestImpl sessionRequest = requestHandle.getSessionRequest();
-
+
// Finish connection process
try {
channel.finishConnect();
@@ -143,20 +143,20 @@ public class DefaultConnectingIOReactor
try {
prepareSocket(channel.socket());
} catch (IOException ex) {
- if (this.exceptionHandler == null
+ if (this.exceptionHandler == null
|| !this.exceptionHandler.handle(ex)) {
throw new IOReactorException(
"Failure initalizing socket", ex);
}
}
- ChannelEntry entry = new ChannelEntry(channel, sessionRequest);
+ ChannelEntry entry = new ChannelEntry(channel, sessionRequest);
addChannel(entry);
} catch (IOException ex) {
sessionRequest.failed(ex);
}
}
}
-
+
} catch (CancelledKeyException ex) {
key.attach(null);
}
@@ -167,7 +167,7 @@ public class DefaultConnectingIOReactor
for (Iterator<SelectionKey> it = keys.iterator(); it.hasNext();) {
SelectionKey key = it.next();
Object attachment = key.attachment();
-
+
if (attachment instanceof SessionRequestHandle) {
SessionRequestHandle handle = (SessionRequestHandle) key.attachment();
SessionRequestImpl sessionRequest = handle.getSessionRequest();
@@ -178,12 +178,12 @@ public class DefaultConnectingIOReactor
}
}
}
-
+
}
}
public SessionRequest connect(
- final SocketAddress remoteAddress,
+ final SocketAddress remoteAddress,
final SocketAddress localAddress,
final Object attachment,
final SessionRequestCallback callback) {
@@ -194,13 +194,13 @@ public class DefaultConnectingIOReactor
SessionRequestImpl sessionRequest = new SessionRequestImpl(
remoteAddress, localAddress, attachment, callback);
sessionRequest.setConnectTimeout(HttpConnectionParams.getConnectionTimeout(this.params));
-
+
this.requestQueue.add(sessionRequest);
this.selector.wakeup();
-
+
return sessionRequest;
}
-
+
private void validateAddress(final SocketAddress address) throws UnknownHostException {
if (address == null) {
return;
@@ -212,7 +212,7 @@ public class DefaultConnectingIOReactor
}
}
}
-
+
private void processSessionRequests() throws IOReactorException {
SessionRequestImpl request;
while ((request = this.requestQueue.poll()) != null) {
@@ -229,7 +229,7 @@ public class DefaultConnectingIOReactor
try {
validateAddress(request.getLocalAddress());
validateAddress(request.getRemoteAddress());
-
+
if (request.getLocalAddress() != null) {
Socket sock = socketChannel.socket();
sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(this.params));
@@ -238,7 +238,7 @@ public class DefaultConnectingIOReactor
boolean connected = socketChannel.connect(request.getRemoteAddress());
if (connected) {
prepareSocket(socketChannel.socket());
- ChannelEntry entry = new ChannelEntry(socketChannel, request);
+ ChannelEntry entry = new ChannelEntry(socketChannel, request);
addChannel(entry);
return;
}
@@ -246,7 +246,7 @@ public class DefaultConnectingIOReactor
request.failed(ex);
return;
}
-
+
SelectionKey key;
try {
key = socketChannel.register(this.selector, 0);
@@ -256,7 +256,7 @@ public class DefaultConnectingIOReactor
"with the selector", ex);
}
- SessionRequestHandle requestHandle = new SessionRequestHandle(request);
+ SessionRequestHandle requestHandle = new SessionRequestHandle(request);
try {
key.attach(requestHandle);
key.interestOps(SelectionKey.OP_CONNECT);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java Fri Apr 23 19:11:53 2010
@@ -48,12 +48,12 @@ import org.apache.http.nio.reactor.Liste
import org.apache.http.params.HttpParams;
/**
- * Default implementation of {@link ListeningIOReactor}. This class extends
+ * Default implementation of {@link ListeningIOReactor}. This class extends
* {@link AbstractMultiworkerIOReactor} with capability to listen for incoming
* connections.
* <p>
- * The following parameters can be used to customize the behavior of this
- * class:
+ * The following parameters can be used to customize the behavior of this
+ * class:
* <ul>
* <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
@@ -65,17 +65,17 @@ import org.apache.http.params.HttpParams
*
* @since 4.0
*/
-public class DefaultListeningIOReactor extends AbstractMultiworkerIOReactor
+public class DefaultListeningIOReactor extends AbstractMultiworkerIOReactor
implements ListeningIOReactor {
private final Queue<ListenerEndpointImpl> requestQueue;
private final Set<ListenerEndpointImpl> endpoints;
private final Set<SocketAddress> pausedEndpoints;
-
+
private volatile boolean paused;
-
+
public DefaultListeningIOReactor(
- int workerCount,
+ int workerCount,
final ThreadFactory threadFactory,
final HttpParams params) throws IOReactorException {
super(workerCount, threadFactory, params);
@@ -85,12 +85,12 @@ public class DefaultListeningIOReactor e
}
public DefaultListeningIOReactor(
- int workerCount,
+ int workerCount,
final HttpParams params) throws IOReactorException {
this(workerCount, null, params);
}
-
-
+
+
@Override
protected void cancelRequests() throws IOReactorException {
ListenerEndpointImpl request;
@@ -108,48 +108,48 @@ public class DefaultListeningIOReactor e
if (readyCount > 0) {
Set<SelectionKey> selectedKeys = this.selector.selectedKeys();
for (Iterator<SelectionKey> it = selectedKeys.iterator(); it.hasNext(); ) {
-
+
SelectionKey key = it.next();
processEvent(key);
-
+
}
selectedKeys.clear();
}
}
- private void processEvent(final SelectionKey key)
+ private void processEvent(final SelectionKey key)
throws IOReactorException {
try {
-
+
if (key.isAcceptable()) {
-
+
ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
SocketChannel socketChannel = null;
try {
socketChannel = serverChannel.accept();
} catch (IOException ex) {
- if (this.exceptionHandler == null ||
+ if (this.exceptionHandler == null ||
!this.exceptionHandler.handle(ex)) {
throw new IOReactorException(
"Failure accepting connection", ex);
}
}
-
+
if (socketChannel != null) {
try {
prepareSocket(socketChannel.socket());
} catch (IOException ex) {
- if (this.exceptionHandler == null ||
+ if (this.exceptionHandler == null ||
!this.exceptionHandler.handle(ex)) {
throw new IOReactorException(
"Failure initalizing socket", ex);
}
}
- ChannelEntry entry = new ChannelEntry(socketChannel);
+ ChannelEntry entry = new ChannelEntry(socketChannel);
addChannel(entry);
}
}
-
+
} catch (CancelledKeyException ex) {
ListenerEndpoint endpoint = (ListenerEndpoint) key.attachment();
this.endpoints.remove(endpoint);
@@ -165,11 +165,11 @@ public class DefaultListeningIOReactor e
public void endpointClosed(final ListenerEndpoint endpoint) {
endpoints.remove(endpoint);
}
-
+
});
return endpoint;
}
-
+
public ListenerEndpoint listen(final SocketAddress address) {
if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0) {
throw new IllegalStateException("I/O reactor has been shut down");
@@ -196,7 +196,7 @@ public class DefaultListeningIOReactor e
} catch (IOException ex) {
request.failed(ex);
if (this.exceptionHandler == null || !this.exceptionHandler.handle(ex)) {
- throw new IOReactorException("Failure binding socket to address "
+ throw new IOReactorException("Failure binding socket to address "
+ address, ex);
} else {
return;
@@ -210,12 +210,12 @@ public class DefaultListeningIOReactor e
throw new IOReactorException("Failure registering channel " +
"with the selector", ex);
}
-
+
this.endpoints.add(request);
request.completed(serverChannel.socket().getLocalSocketAddress());
}
}
-
+
public Set<ListenerEndpoint> getEndpoints() {
Set<ListenerEndpoint> set = new HashSet<ListenerEndpoint>();
synchronized (this.endpoints) {
@@ -262,5 +262,5 @@ public class DefaultListeningIOReactor e
this.pausedEndpoints.clear();
this.selector.wakeup();
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ExceptionEvent.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ExceptionEvent.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ExceptionEvent.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ExceptionEvent.java Fri Apr 23 19:11:53 2010
@@ -30,7 +30,7 @@ package org.apache.http.impl.nio.reactor
import java.util.Date;
/**
- * A {@link Throwable} instance along with a time stamp.
+ * A {@link Throwable} instance along with a time stamp.
*
* @since 4.0
*/
@@ -38,17 +38,17 @@ public class ExceptionEvent {
private final Throwable ex;
private final long time;
-
+
public ExceptionEvent(final Throwable ex, final Date timestamp) {
super();
this.ex = ex;
if (timestamp != null) {
- this.time = timestamp.getTime();
+ this.time = timestamp.getTime();
} else {
this.time = 0;
}
}
-
+
public ExceptionEvent(final Exception ex) {
this(ex, new Date());
}
@@ -69,5 +69,5 @@ public class ExceptionEvent {
buffer.append(this.ex);
return buffer.toString();
}
-
+
}