You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2010/01/26 16:07:32 UTC
svn commit: r903254 -
/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
Author: gnodet
Date: Tue Jan 26 15:07:32 2010
New Revision: 903254
URL: http://svn.apache.org/viewvc?rev=903254&view=rev
Log:
SMXCOMP-161: fix synchronization issue caused by a previous commit
Modified:
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.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=903254&r1=903253&r2=903254&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 Jan 26 15:07:32 2010
@@ -246,7 +246,7 @@
} else {
isSTFlow = false;
// synchronized block
- synchronized (cont) {
+ synchronized (cont.getObject()) {
if (locks.remove(exchange.getExchangeId()) == null) {
throw new Exception("HTTP request has timed out for exchange: "
+ exchange.getExchangeId());
@@ -299,7 +299,7 @@
request.setAttribute(MessageExchange.class.getName(), exchange.getExchangeId());
// Put the continuation in a map under the exchange id key
locks.put(exchange.getExchangeId(), cont);
- synchronized (cont) {
+ synchronized (cont.getObject()) {
// Send the exchange
send(exchange);
if (!isSTFlow) {
@@ -353,7 +353,7 @@
// * the continuation has been resumed because the exchange has been received
// * the continuation has timed out
} else {
- synchronized (cont) {
+ synchronized (cont.getObject()) {
// Get the exchange id from the request
String id = (String) request.getAttribute(MessageExchange.class.getName());
// Remove the continuation from the map, indicating it has been processed or timed out
@@ -376,7 +376,7 @@
if (exchange.getStatus() == ExchangeStatus.ERROR) {
Exception e = exchange.getError();
if (e == null) {
- e = new Exception("Unkown error (exchange aborted ?)");
+ e = new Exception("Unknown error (exchange aborted ?)");
}
throw e;
} else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
@@ -409,13 +409,16 @@
private Continuation createContinuation(HttpServletRequest request) {
// not giving a specific mutex will synchronize on the continuation itself
Continuation continuation = ContinuationSupport.getContinuation(request, null);
- if (continuation instanceof WaitingContinuation) {
- return continuation;
- } else {
- // wrap the continuation to avoid a deadlock between this endpoint and the Jetty continuation timeout mechanism
- // the endpoint now synchronizes on the wrapper while Jetty synchronizes on the continuation itself
- return new ContinuationWrapper(continuation);
+ // Set the continuation's object that the endpoint will use to synchronize on to avoid a
+ // deadlock between this endpoint and the Jetty continuation timeout mechanism
+ // the endpoint now synchronizes on the continuation's object while Jetty synchronizes on
+ // the continuation itself
+ synchronized (continuation) {
+ if (continuation.getObject() == null) {
+ continuation.setObject(new Object());
+ }
}
+ return continuation;
}
protected void loadStaticResources() throws Exception {