You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by cc...@apache.org on 2010/07/20 20:25:42 UTC
svn commit: r965944 - in
/servicemix/components/bindings/servicemix-http/trunk/src:
main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
Author: ccustine
Date: Tue Jul 20 18:25:42 2010
New Revision: 965944
URL: http://svn.apache.org/viewvc?rev=965944&view=rev
Log:
SMXCOMP-781 - Component is not owner exceptions on HTTP consumer timeout
Modified:
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java?rev=965944&r1=965943&r2=965944&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java Tue Jul 20 18:25:42 2010
@@ -264,7 +264,12 @@ public class HttpConsumerEndpoint extend
return;
}
Continuation cont = createContinuation(request);
- // If the continuation is not a retry
+
+ long to = this.timeout;
+ if (to == 0) {
+ to = ((HttpComponent) getServiceUnit().getComponent()).getConfiguration().getConsumerProcessorSuspendTime();
+ }
+
if (!cont.isPending()) {
// Check endpoint is started
if (!started) {
@@ -280,10 +285,6 @@ public class HttpConsumerEndpoint extend
if (logger.isDebugEnabled()) {
logger.debug("Suspending continuation for exchange: " + exchange.getExchangeId());
}
- long to = this.timeout;
- if (to == 0) {
- to = ((HttpComponent) getServiceUnit().getComponent()).getConfiguration().getConsumerProcessorSuspendTime();
- }
synchronized (cont) {
// Send the exchange and then suspend the request.
send(exchange);
@@ -292,26 +293,33 @@ public class HttpConsumerEndpoint extend
// will throw a RetryRequest exception
// else, the call will block until the continuation is
// resumed
- cont.suspend(to);
+ boolean istimeout = !cont.suspend(to);
// The call has not thrown a RetryRequest, which means
// we don't use a SelectConnector
// and we must handle the exchange in this very method
// call.
// If result is false, the continuation has timed out.
locks.remove(exchange.getExchangeId());
+
+ // Timeout if SelectConnector is not used
+ if (istimeout) {
+ throw new Exception("HTTP request has timed out for exchange: " + exchange.getExchangeId());
+ }
}
} else {
// The continuation is a retry.
// This happens when the SelectConnector is used and in two cases:
// * the continuation has been resumed because the exchange has been received
// * the continuation has timed out
+ boolean istimeout = !cont.suspend(to);
exchange = (MessageExchange) cont.getObject();
// Remove the continuation from the map, indicating it has been processed or timed out
locks.remove(exchange.getExchangeId());
- // Check if this is a timeout
- //if (exchange == null) {
- // throw new IllegalStateException("Exchange not found");
- //}
+
+ // Timeout
+ if (istimeout) {
+ throw new Exception("HTTP request has timed out for exchange: " + exchange.getExchangeId());
+ }
}
// At this point, we have received the exchange response,
// so process it and send back the HTTP response
@@ -520,4 +528,4 @@ public class HttpConsumerEndpoint extend
return continuation.suspend(timeout);
}
}
-}
\ No newline at end of file
+}
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java?rev=965944&r1=965943&r2=965944&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java Tue Jul 20 18:25:42 2010
@@ -190,7 +190,8 @@ public class ConsumerEndpointTest extend
new HttpClient().executeMethod(post);
String res = post.getResponseBodyAsString();
log.info(res);
- if (post.getStatusCode() != 500) {
+
+ if (post.getStatusCode() != 500 || !res.contains("HTTP request has timed out for exchange")) {
throw new InvalidStatusResponseException(post.getStatusCode());
}
Thread.sleep(1000);