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 2007/04/27 16:13:54 UTC

svn commit: r533106 - /incubator/servicemix/branches/servicemix-3.1/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/BeanEndpoint.java

Author: gnodet
Date: Fri Apr 27 07:13:53 2007
New Revision: 533106

URL: http://svn.apache.org/viewvc?view=rev&rev=533106
Log:
SM-941: NPE in BeanComponent - checkEndOfRequest

Modified:
    incubator/servicemix/branches/servicemix-3.1/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/BeanEndpoint.java

Modified: incubator/servicemix/branches/servicemix-3.1/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/BeanEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/BeanEndpoint.java?view=diff&rev=533106&r1=533105&r2=533106
==============================================================================
--- incubator/servicemix/branches/servicemix-3.1/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/BeanEndpoint.java (original)
+++ incubator/servicemix/branches/servicemix-3.1/deployables/serviceengines/servicemix-bean/src/main/java/org/apache/servicemix/bean/BeanEndpoint.java Fri Apr 27 07:13:53 2007
@@ -218,45 +218,47 @@
             requests.put(corId, req);
         }
         currentRequest.set(req);
-        // If the bean implements MessageExchangeListener,
-        // just call the method
-        if (req.getBean() instanceof MessageExchangeListener) {
-            ((MessageExchangeListener) req.getBean()).onMessageExchange(exchange);
-        } else {
-            // Exchange is finished
-            if (exchange.getStatus() == ExchangeStatus.DONE) {
-                return;
-            }
-            // Exchange has been aborted with an exception
-            else if (exchange.getStatus() == ExchangeStatus.ERROR) {
-                return;
-                // Fault message
-            } else if (exchange.getFault() != null) {
-                // TODO: find a way to send it back to the bean before setting the DONE status
-                done(exchange);
+        synchronized (req) {
+            // If the bean implements MessageExchangeListener,
+            // just call the method
+            if (req.getBean() instanceof MessageExchangeListener) {
+                ((MessageExchangeListener) req.getBean()).onMessageExchange(exchange);
             } else {
-                MethodInvocation invocation = getMethodInvocationStrategy().createInvocation(req.getBean(), getBeanInfo(), exchange, this);
-                if (invocation == null) {
-                    throw new UnknownMessageExchangeTypeException(exchange, this);
-                }
-                try {
-                    invocation.proceed();
-                } catch (Exception e) {
-                    throw e;
-                } catch (Throwable throwable) {
-                    throw new MethodInvocationFailedException(req.getBean(), invocation, exchange, this, throwable);
-                }
-                if (exchange.getStatus() == ExchangeStatus.ERROR) {
-                    send(exchange);
+                // Exchange is finished
+                if (exchange.getStatus() == ExchangeStatus.DONE) {
+                    return;
                 }
-                if (exchange.getFault() == null && exchange.getMessage("out") == null)  {
-                    // TODO: handle MEP correctly (DONE should only be sent for InOnly)
+                // Exchange has been aborted with an exception
+                else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+                    return;
+                    // Fault message
+                } else if (exchange.getFault() != null) {
+                    // TODO: find a way to send it back to the bean before setting the DONE status
                     done(exchange);
+                } else {
+                    MethodInvocation invocation = getMethodInvocationStrategy().createInvocation(req.getBean(), getBeanInfo(), exchange, this);
+                    if (invocation == null) {
+                        throw new UnknownMessageExchangeTypeException(exchange, this);
+                    }
+                    try {
+                        invocation.proceed();
+                    } catch (Exception e) {
+                        throw e;
+                    } catch (Throwable throwable) {
+                        throw new MethodInvocationFailedException(req.getBean(), invocation, exchange, this, throwable);
+                    }
+                    if (exchange.getStatus() == ExchangeStatus.ERROR) {
+                        send(exchange);
+                    }
+                    if (exchange.getFault() == null && exchange.getMessage("out") == null)  {
+                        // TODO: handle MEP correctly (DONE should only be sent for InOnly)
+                        done(exchange);
+                    }
                 }
             }
+            checkEndOfRequest(req);
+            currentRequest.set(null);
         }
-        checkEndOfRequest(req);
-        currentRequest.set(null);
     }
     
     protected void onConsumerExchange(MessageExchange exchange) throws Exception {