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 2011/09/13 14:25:02 UTC
svn commit: r1170136 - in /httpcomponents/httpcore/trunk:
httpcore-nio/src/examples/org/apache/http/examples/nio/
httpcore-nio/src/main/java/org/apache/http/nio/protocol/
httpcore-nio/src/test/java/org/apache/http/nio/protocol/
httpcore/src/main/java/o...
Author: olegk
Date: Tue Sep 13 12:25:01 2011
New Revision: 1170136
URL: http://svn.apache.org/viewvc?rev=1170136&view=rev
Log:
HTTPCORE-272: facility to abort long running async request handlers
Added:
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java (with props)
Modified:
httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BufferingAsyncRequestHandler.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandlerImpl.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncContinueTrigger.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExpectationVerifier.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestHandler.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java
httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/FutureCallback.java
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java Tue Sep 13 12:25:01 2011
@@ -44,6 +44,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.EnglishReasonPhraseCatalog;
@@ -373,7 +374,7 @@ public class NHttpReverseProxy {
}
}
- public void handle(
+ public Cancellable handle(
final ProxyHttpExchange httpExchange,
final HttpAsyncResponseTrigger responseTrigger,
final HttpContext context) throws HttpException, IOException {
@@ -391,16 +392,17 @@ public class NHttpReverseProxy {
response.setEntity(NStringEntity.create(message, ContentType.DEFAULT_TEXT));
responseTrigger.submitResponse(new BasicAsyncResponseProducer(response));
System.out.println("[client<-proxy] " + httpExchange.getId() + " error response triggered");
- return;
+ return null;
}
HttpResponse response = httpExchange.getResponse();
if (response != null) {
responseTrigger.submitResponse(new ProxyResponseProducer(httpExchange));
System.out.println("[client<-proxy] " + httpExchange.getId() + " response triggered");
- return;
+ return null;
}
// No response yet.
httpExchange.setResponseTrigger(responseTrigger);
+ return null;
}
}
@@ -665,8 +667,9 @@ public class NHttpReverseProxy {
}
}
- public void cancel() {
+ public boolean cancel() {
failed(new InterruptedIOException("Cancelled"));
+ return true;
}
public ProxyHttpExchange getResult() {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpServer.java Tue Sep 13 12:25:01 2011
@@ -48,6 +48,7 @@ import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
import org.apache.http.MethodNotSupportedException;
import org.apache.http.ProtocolVersion;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpResponseFactory;
@@ -193,7 +194,7 @@ public class NHttpServer {
return new BasicAsyncRequestConsumer();
}
- public void handle(
+ public Cancellable handle(
final HttpRequest request,
final HttpAsyncResponseTrigger trigger,
final HttpContext context) throws HttpException, IOException {
@@ -204,6 +205,7 @@ public class NHttpServer {
HttpResponse response = this.responseFactory.newHttpResponse(ver, HttpStatus.SC_OK, context);
handleInternal(request, response, context);
trigger.submitResponse(new BasicAsyncResponseProducer(response));
+ return null;
}
private void handleInternal(
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java Tue Sep 13 12:25:01 2011
@@ -81,12 +81,13 @@ public abstract class AbstractAsyncRespo
}
}
- public synchronized void cancel() {
+ public synchronized boolean cancel() {
if (this.completed) {
- return;
+ return false;
}
this.completed = true;
releaseResources();
+ return true;
}
public synchronized void failed(final Exception ex) {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BufferingAsyncRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BufferingAsyncRequestHandler.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BufferingAsyncRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BufferingAsyncRequestHandler.java Tue Sep 13 12:25:01 2011
@@ -37,6 +37,7 @@ import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
import org.apache.http.ProtocolVersion;
import org.apache.http.annotation.Immutable;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.nio.util.ByteBufferAllocator;
import org.apache.http.nio.util.HeapByteBufferAllocator;
@@ -81,7 +82,7 @@ public class BufferingAsyncRequestHandle
return new BasicAsyncRequestConsumer(this.allocator);
}
- public void handle(final HttpRequest request, final HttpAsyncResponseTrigger trigger,
+ public Cancellable handle(final HttpRequest request, final HttpAsyncResponseTrigger trigger,
final HttpContext context) throws HttpException, IOException {
ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
@@ -90,6 +91,7 @@ public class BufferingAsyncRequestHandle
HttpResponse response = this.responseFactory.newHttpResponse(ver, HttpStatus.SC_OK, context);
this.handler.handle(request, response, context);
trigger.submitResponse(new BasicAsyncResponseProducer(response));
+ return null;
}
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandlerImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandlerImpl.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandlerImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandlerImpl.java Tue Sep 13 12:25:01 2011
@@ -179,9 +179,9 @@ class HttpAsyncClientExchangeHandlerImpl
}
}
- public void cancel() {
+ public boolean cancel() {
try {
- this.responseConsumer.cancel();
+ return this.responseConsumer.cancel();
} catch (RuntimeException ex) {
failed(ex);
throw ex;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncContinueTrigger.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncContinueTrigger.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncContinueTrigger.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncContinueTrigger.java Tue Sep 13 12:25:01 2011
@@ -30,12 +30,8 @@ package org.apache.http.nio.protocol;
/**
* @since 4.2
*/
-public interface HttpAsyncContinueTrigger {
+public interface HttpAsyncContinueTrigger extends HttpAsyncResponseTrigger {
void continueRequest();
- void submitResponse(HttpAsyncResponseProducer responseProducer);
-
- boolean isTriggered();
-
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExpectationVerifier.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExpectationVerifier.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExpectationVerifier.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncExpectationVerifier.java Tue Sep 13 12:25:01 2011
@@ -31,6 +31,7 @@ import java.io.IOException;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.protocol.HttpContext;
/**
@@ -38,7 +39,7 @@ import org.apache.http.protocol.HttpCont
*/
public interface HttpAsyncExpectationVerifier {
- void verify(
+ Cancellable verify(
HttpRequest request,
HttpAsyncContinueTrigger trigger,
HttpContext context) throws HttpException, IOException;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestHandler.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncRequestHandler.java Tue Sep 13 12:25:01 2011
@@ -31,6 +31,7 @@ import java.io.IOException;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.protocol.HttpContext;
/**
@@ -42,7 +43,7 @@ public interface HttpAsyncRequestHandler
HttpRequest request,
HttpContext context);
- void handle(
+ Cancellable handle(
T data,
HttpAsyncResponseTrigger trigger,
HttpContext context) throws HttpException, IOException;
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java Tue Sep 13 12:25:01 2011
@@ -31,6 +31,7 @@ import java.io.IOException;
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.IOControl;
import org.apache.http.protocol.HttpContext;
@@ -38,7 +39,7 @@ import org.apache.http.protocol.HttpCont
/**
* @since 4.2
*/
-public interface HttpAsyncResponseConsumer<T> extends Closeable {
+public interface HttpAsyncResponseConsumer<T> extends Closeable, Cancellable {
void responseReceived(HttpResponse response) throws IOException, HttpException;
@@ -48,8 +49,6 @@ public interface HttpAsyncResponseConsum
void failed(Exception ex);
- void cancel();
-
T getResult();
Exception getException();
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncServiceHandler.java Tue Sep 13 12:25:01 2011
@@ -42,6 +42,7 @@ import org.apache.http.ProtocolException
import org.apache.http.ProtocolVersion;
import org.apache.http.UnsupportedHttpVersionException;
import org.apache.http.annotation.Immutable;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.ContentEncoder;
@@ -112,7 +113,11 @@ public class HttpAsyncServiceHandler imp
public void closed(final NHttpServerConnection conn) {
HttpExchange httpExchange = (HttpExchange) conn.getContext().getAttribute(HTTP_EXCHANGE);
+ Cancellable asyncProcess = httpExchange.getAsyncProcess();
httpExchange.clear();
+ if (asyncProcess != null) {
+ asyncProcess.cancel();
+ }
}
public void requestReceived(final NHttpServerConnection conn) {
@@ -142,7 +147,8 @@ public class HttpAsyncServiceHandler imp
if (this.expectationVerifier != null) {
conn.suspendInput();
HttpAsyncContinueTrigger trigger = new ContinueTriggerImpl(httpExchange, conn);
- this.expectationVerifier.verify(request, trigger, context);
+ Cancellable asyncProcess = this.expectationVerifier.verify(request, trigger, context);
+ httpExchange.setAsyncProcess(asyncProcess);
} else {
HttpResponse response = create100Continue(request);
conn.submitResponse(response);
@@ -360,7 +366,8 @@ public class HttpAsyncServiceHandler imp
Object result = consumer.getResult();
HttpAsyncResponseTrigger trigger = new ResponseTriggerImpl(httpExchange, conn);
try {
- handler.handle(result, trigger, context);
+ Cancellable asyncProcess = handler.handle(result, trigger, context);
+ httpExchange.setAsyncProcess(asyncProcess);
} catch (HttpException ex) {
HttpAsyncResponseProducer responseProducer = handleException(ex);
httpExchange.setResponseProducer(responseProducer);
@@ -432,6 +439,7 @@ public class HttpAsyncServiceHandler imp
private volatile HttpAsyncResponseProducer responseProducer;
private volatile HttpRequest request;
private volatile HttpResponse response;
+ private volatile Cancellable asyncProcess;
HttpExchange() {
super();
@@ -514,6 +522,14 @@ public class HttpAsyncServiceHandler imp
this.response = response;
}
+ public Cancellable getAsyncProcess() {
+ return this.asyncProcess;
+ }
+
+ public void setAsyncProcess(final Cancellable asyncProcess) {
+ this.asyncProcess = asyncProcess;
+ }
+
public void clear() {
this.responseState = MessageState.READY;
this.requestState = MessageState.READY;
@@ -536,6 +552,7 @@ public class HttpAsyncServiceHandler imp
this.responseProducer = null;
this.request = null;
this.response = null;
+ this.asyncProcess = null;
this.context.clear();
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/protocol/NullRequestHandler.java Tue Sep 13 12:25:01 2011
@@ -30,6 +30,7 @@ package org.apache.http.nio.protocol;
import org.apache.http.HttpRequest;
import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.nio.entity.NStringEntity;
import org.apache.http.protocol.HttpContext;
@@ -44,13 +45,14 @@ class NullRequestHandler implements Http
return new NullRequestConsumer();
}
- public void handle(
+ public Cancellable handle(
final Object obj,
final HttpAsyncResponseTrigger trigger,
final HttpContext context) {
trigger.submitResponse(new ErrorResponseProducer(
HttpVersion.HTTP_1_0, HttpStatus.SC_NOT_IMPLEMENTED,
NStringEntity.create("Service not implemented"), true));
+ return null;
}
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncHandlers.java Tue Sep 13 12:25:01 2011
@@ -43,6 +43,7 @@ import org.apache.http.HttpVersion;
import org.apache.http.LoggingClientConnectionFactory;
import org.apache.http.LoggingServerConnectionFactory;
import org.apache.http.ProtocolVersion;
+import org.apache.http.concurrent.Cancellable;
import org.apache.http.entity.ContentType;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
@@ -375,7 +376,7 @@ public class TestHttpAsyncHandlers exten
public void testHttpPostsWithExpectationVerification() throws Exception {
HttpAsyncExpectationVerifier expectationVerifier = new HttpAsyncExpectationVerifier() {
- public void verify(
+ public Cancellable verify(
final HttpRequest request,
final HttpAsyncContinueTrigger trigger,
final HttpContext context) throws HttpException {
@@ -392,6 +393,7 @@ public class TestHttpAsyncHandlers exten
} else {
trigger.continueRequest();
}
+ return null;
}
};
@@ -457,7 +459,7 @@ public class TestHttpAsyncHandlers exten
return new BasicAsyncRequestConsumer();
}
- public void handle(
+ public Cancellable handle(
final HttpRequest request,
final HttpAsyncResponseTrigger trigger,
final HttpContext context) throws HttpException, IOException {
@@ -480,6 +482,7 @@ public class TestHttpAsyncHandlers exten
trigger.submitResponse(new BasicAsyncResponseProducer(response));
}
}.start();
+ return null;
}
}
@@ -518,7 +521,7 @@ public class TestHttpAsyncHandlers exten
public void testHttpPostsWithExpectationVerificationDelayedResponse() throws Exception {
HttpAsyncExpectationVerifier expectationVerifier = new HttpAsyncExpectationVerifier() {
- public void verify(
+ public Cancellable verify(
final HttpRequest request,
final HttpAsyncContinueTrigger trigger,
final HttpContext context) throws HttpException {
@@ -543,6 +546,7 @@ public class TestHttpAsyncHandlers exten
}
}
}.start();
+ return null;
}
};
@@ -605,7 +609,7 @@ public class TestHttpAsyncHandlers exten
return new BasicAsyncRequestConsumer();
}
- public void handle(
+ public Cancellable handle(
final HttpRequest request,
final HttpAsyncResponseTrigger trigger,
final HttpContext context) throws HttpException, IOException {
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java Tue Sep 13 12:25:01 2011
@@ -31,7 +31,10 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-public class BasicFuture<T> implements Future<T> {
+/**
+ * @since 4.2
+ */
+public class BasicFuture<T> implements Future<T>, Cancellable {
private final FutureCallback<T> callback;
@@ -130,4 +133,8 @@ public class BasicFuture<T> implements F
return true;
}
+ public boolean cancel() {
+ return cancel(true);
+ }
+
}
Added: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java?rev=1170136&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java (added)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java Tue Sep 13 12:25:01 2011
@@ -0,0 +1,36 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.concurrent;
+
+/**
+ * @since 4.2
+ */
+public interface Cancellable {
+
+ boolean cancel();
+
+}
Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/Cancellable.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/FutureCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/FutureCallback.java?rev=1170136&r1=1170135&r2=1170136&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/FutureCallback.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/concurrent/FutureCallback.java Tue Sep 13 12:25:01 2011
@@ -26,6 +26,9 @@
*/
package org.apache.http.concurrent;
+/**
+ * @since 4.2
+ */
public interface FutureCallback<T> {
void completed(T result);