cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r827050 - in /cxf/trunk/rt/management/src: main/java/org/apache/cxf/management/interceptor/ test/java/org/apache/cxf/management/interceptor/
Date Tue, 20 Oct 2009 12:30:01 GMT
Author: eglynn
Date: Tue Oct 20 12:30:00 2009
New Revision: 827050

URL: http://svn.apache.org/viewvc?rev=827050&view=rev
Log:
Fix for for [CXF-2305] PerformanceCounter.Client reports incorrect response times for oneway
invocations

Modified:
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
    cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
    cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java?rev=827050&r1=827049&r2=827050&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
Tue Oct 20 12:30:00 2009
@@ -35,7 +35,9 @@
         
         Exchange ex = message.getExchange();        
         if (isClient(message)) {
-            endHandlingMessage(ex);
+            if (!ex.isOneWay()) {
+                endHandlingMessage(ex);
+            }
         } else {            
             beginHandlingMessage(ex);            
         }

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java?rev=827050&r1=827049&r2=827050&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
Tue Oct 20 12:30:00 2009
@@ -40,7 +40,7 @@
     
     public void handleMessage(Message message) throws Fault {
         Exchange ex = message.getExchange();
-        if (ex.isOneWay()) {
+        if (ex.isOneWay() && !isClient(message)) {
             setOneWayMessage(ex);
         }
     }
@@ -49,7 +49,7 @@
     public void handleFault(Message message) {
         Exchange ex = message.getExchange();
         ex.put(FaultMode.class, message.get(FaultMode.class));
-        if (ex.isOneWay()) {
+        if (ex.isOneWay() && !isClient(message)) {
             endHandlingMessage(ex);
         }
     }

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java?rev=827050&r1=827049&r2=827050&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
Tue Oct 20 12:30:00 2009
@@ -22,10 +22,12 @@
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 
 public class ResponseTimeMessageOutInterceptor extends AbstractMessageResponseTimeInterceptor
{
-    
+    private EndingInterceptor ending = new EndingInterceptor(); 
+
     public ResponseTimeMessageOutInterceptor() {
         super(Phase.SEND);
     }
@@ -34,10 +36,9 @@
         Exchange ex = message.getExchange();
         if (isClient(message)) {
             if (ex.isOneWay()) {
-                setOneWayMessage(ex);
-            } else {
-                beginHandlingMessage(ex);
-            }
+                message.getInterceptorChain().add(ending);
+            } 
+            beginHandlingMessage(ex);
         } else { // the message is handled by server
             endHandlingMessage(ex);
         }
@@ -58,4 +59,24 @@
             endHandlingMessage(ex);
         }
     }
+
+    EndingInterceptor getEndingInterceptor() {
+        return ending;
+    }
+    
+    public class EndingInterceptor extends AbstractPhaseInterceptor<Message> {
+        public EndingInterceptor() {
+            super(Phase.PREPARE_SEND_ENDING);
+        }
+
+        public void handleMessage(Message message) throws Fault {
+            Exchange ex = message.getExchange();
+            endHandlingMessage(ex);
+        }
+
+        public void handleFault(Message message) throws Fault {
+            Exchange ex = message.getExchange();
+            endHandlingMessage(ex);
+        }
+    }
 }

Modified: cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java?rev=827050&r1=827049&r2=827050&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
(original)
+++ cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
Tue Oct 20 12:30:00 2009
@@ -39,6 +39,7 @@
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
         EasyMock.expect(exchange.getOutMessage()).andReturn(message);
         EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
+        EasyMock.expect(exchange.isOneWay()).andReturn(false);
         MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         mhtr.endHandling();
         EasyMock.expectLastCall();        

Modified: cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java?rev=827050&r1=827049&r2=827050&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
(original)
+++ cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
Tue Oct 20 12:30:00 2009
@@ -18,6 +18,8 @@
  */
 
 package org.apache.cxf.management.interceptor;
+
+import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.management.counters.MessageHandlingTimeRecorder;
 import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.Message;
@@ -113,23 +115,28 @@
         //need to increase the counter and is a client
         setupCounterRepository(true, true);
         setupExchangeForMessage();
-        EasyMock.expect(message.getExchange()).andReturn(exchange);
+        EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();

         EasyMock.expect(exchange.getOutMessage()).andReturn(message);
+        EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
         //MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         //mhtr.setOneWay(true);
         //EasyMock.expectLastCall();
          
         //EasyMock.replay(mhtr);
-        EasyMock.expect(exchange.isOneWay()).andReturn(true);
-        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null);
       
-        exchange.put(EasyMock.eq(MessageHandlingTimeRecorder.class), 
-                     EasyMock.isA(MessageHandlingTimeRecorder.class));
+        EasyMock.expect(exchange.isOneWay()).andReturn(true).anyTimes();
+        MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
+        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr).anyTimes();
       
+        InterceptorChain chain = EasyMock.createMock(InterceptorChain.class);
+        EasyMock.expect(message.getInterceptorChain()).andReturn(chain);
+        chain.add(EasyMock.isA(ResponseTimeMessageOutInterceptor.EndingInterceptor.class));
         EasyMock.expectLastCall();
         EasyMock.replay(exchange);
         EasyMock.replay(message);
         
         rtmoi.handleMessage(message);
+        rtmoi.getEndingInterceptor().handleMessage(message);
+
         EasyMock.verify(message);
         EasyMock.verify(bus);
         EasyMock.verify(exchange);



Mime
View raw message