cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [6/6] git commit: [CXF-5847]:More fix to enable/disable ResponseTimeCounter
Date Mon, 07 Jul 2014 06:44:11 GMT
[CXF-5847]:More fix to enable/disable ResponseTimeCounter


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9a523190
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9a523190
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9a523190

Branch: refs/heads/master
Commit: 9a5231905e144ca1b9f195487700a355902e8a6f
Parents: 00e33d3
Author: Jim Ma <ema@apache.org>
Authored: Mon Jul 7 14:41:02 2014 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Mon Jul 7 14:43:39 2014 +0800

----------------------------------------------------------------------
 .../ResponseTimeMessageInInterceptor.java       |  1 -
 .../ResponseTimeMessageInvokerInterceptor.java  |  6 ++++--
 .../ResponseTimeMessageOutInterceptor.java      |  3 ++-
 .../AbstractMessageResponseTestBase.java        |  3 ---
 .../ResponseTimeMessageInInterceptorTest.java   |  3 ---
 .../ResponseTimeMessageOutInterceptorTest.java  | 20 ++++++++++++++++----
 6 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9a523190/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
index 04dd0be..af4a8b6 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
@@ -38,7 +38,6 @@ public class ResponseTimeMessageInInterceptor extends AbstractMessageResponseTim
         //if serviceCounter is disabled , all responseTimeInterceptors will be skipped
         Boolean forceDisabled = Boolean.FALSE.equals((Boolean)ex.get("org.apache.cxf.management.counter.enabled"));
         if (isServiceCounterEnabled(ex) && !forceDisabled) {           
-            ex.put("org.apache.cxf.management.counter.enabled", true);
             if (isClient(message)) {
                 if (!ex.isOneWay()) {
                     endHandlingMessage(ex);

http://git-wip-us.apache.org/repos/asf/cxf/blob/9a523190/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
index 2181f2c..2e74833 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInvokerInterceptor.java
@@ -40,7 +40,8 @@ public class ResponseTimeMessageInvokerInterceptor extends AbstractMessageRespon
 
     public void handleMessage(Message message) throws Fault {
         Exchange ex = message.getExchange();
-        if (Boolean.TRUE.equals((Boolean)ex.get("org.apache.cxf.management.counter.enabled")))
{
+        Boolean forceDisabled = Boolean.FALSE.equals((Boolean)ex.get("org.apache.cxf.management.counter.enabled"));
+        if (isServiceCounterEnabled(ex) && !forceDisabled) {  
             message.getInterceptorChain().add(new ResponseTimeMessageInvokerEndingInteceptor());
         }
 
@@ -49,7 +50,8 @@ public class ResponseTimeMessageInvokerInterceptor extends AbstractMessageRespon
     @Override
     public void handleFault(Message message) {
         Exchange ex = message.getExchange();
-        if (ex.get("org.apache.cxf.management.counter.enabled") != null) {
+        Boolean forceDisabled = Boolean.FALSE.equals((Boolean)ex.get("org.apache.cxf.management.counter.enabled"));
+        if (isServiceCounterEnabled(ex) && !forceDisabled) { 
             ex.put(FaultMode.class, message.get(FaultMode.class));
             if (ex.isOneWay() && !isClient(message)) {
                 endHandlingMessage(ex);

http://git-wip-us.apache.org/repos/asf/cxf/blob/9a523190/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
index c0adba0..0ac533a 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
@@ -36,7 +36,8 @@ public class ResponseTimeMessageOutInterceptor extends AbstractMessageResponseTi
     
     public void handleMessage(Message message) throws Fault {
         Exchange ex = message.getExchange();
-        if (Boolean.TRUE.equals((Boolean)ex.get("org.apache.cxf.management.counter.enabled")))
{
+        Boolean forceDisabled = Boolean.FALSE.equals((Boolean)ex.get("org.apache.cxf.management.counter.enabled"));
+        if (isServiceCounterEnabled(ex) && !forceDisabled) {
             if (ex.get(Exception.class) != null) {
                 endHandlingMessage(ex);
                 return;

http://git-wip-us.apache.org/repos/asf/cxf/blob/9a523190/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
index 42846b1..751f903 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTestBase.java
@@ -124,9 +124,6 @@ public class AbstractMessageResponseTestBase extends Assert {
         
         //EasyMock.expect(exchange.getBus()).andReturn(bus);
         EasyMock.expect(exchange.get("org.apache.cxf.management.service.counter.name")).andReturn(null).anyTimes();
-        
-            
-        
     }
       
     protected void setupOperationForMessage() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/9a523190/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
index 9f52bf6..8cbf512 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptorTest.java
@@ -42,7 +42,6 @@ public class ResponseTimeMessageInInterceptorTest extends AbstractMessageRespons
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
         EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
         EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
-        EasyMock.expect(exchange.put("org.apache.cxf.management.counter.enabled", true)).andReturn(true);
         
         EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
         EasyMock.expect(exchange.isOneWay()).andReturn(false);
@@ -128,7 +127,6 @@ public class ResponseTimeMessageInInterceptorTest extends AbstractMessageRespons
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
-        EasyMock.expect(exchange.put("org.apache.cxf.management.counter.enabled", true)).andReturn(true);
         EasyMock.expect(exchange.getOutMessage()).andReturn(message);
         MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         mhtr.beginHandling();
@@ -155,7 +153,6 @@ public class ResponseTimeMessageInInterceptorTest extends AbstractMessageRespons
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
         EasyMock.expect(exchange.getOutMessage()).andReturn(message);
-        EasyMock.expect(exchange.put("org.apache.cxf.management.counter.enabled", true)).andReturn(true);

         EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(null);
         exchange.put(EasyMock.eq(MessageHandlingTimeRecorder.class), 
                      EasyMock.isA(MessageHandlingTimeRecorder.class));

http://git-wip-us.apache.org/repos/asf/cxf/blob/9a523190/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
index 1c49393..31ead54 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.management.interceptor;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.management.counters.MessageHandlingTimeRecorder;
 import org.apache.cxf.message.FaultMode;
@@ -34,12 +35,20 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         // need to increase the counter and is not a client
         setupCounterRepository(true, false);
         setupExchangeForMessage();
+        setupOperationForMessage();
         EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
-
+        EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
         EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
-        MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
        
+        EasyMock.expect(exchange.get(Exception.class)).andReturn(null);
+        EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
+        MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
+        mhtr.endHandling();
+        EasyMock.expectLastCall();
+        mhtr.setFaultMode(null);
+        EasyMock.expectLastCall();
+        EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr).anyTimes();
         EasyMock.replay(mhtr);      
         EasyMock.replay(exchange);
         EasyMock.replay(message);
@@ -104,14 +113,16 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
         EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
         EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();

-        EasyMock.expect(exchange.getOutMessage()).andReturn(message);
+        EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
         EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
+        EasyMock.expect(exchange.get(Exception.class)).andReturn(null);
         EasyMock.expect(exchange.isOneWay()).andReturn(true).anyTimes();
         MessageHandlingTimeRecorder mhtr = EasyMock.createMock(MessageHandlingTimeRecorder.class);
         EasyMock.expect(exchange.get(MessageHandlingTimeRecorder.class)).andReturn(mhtr).anyTimes();
         EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
+        
         InterceptorChain chain = EasyMock.createMock(InterceptorChain.class);
-        //EasyMock.expect(message.getInterceptorChain()).andReturn(chain);
+        EasyMock.expect(message.getInterceptorChain()).andReturn(chain);
         chain.add(EasyMock.isA(ResponseTimeMessageOutInterceptor.EndingInterceptor.class));
         EasyMock.expectLastCall();
         EasyMock.replay(exchange);
@@ -129,6 +140,7 @@ public class ResponseTimeMessageOutInterceptorTest extends AbstractMessageRespon
     public void testClientMessageOut() {
         EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(message.getExchange()).andReturn(exchange);
+        EasyMock.expect(exchange.get(Bus.class)).andReturn(bus);
         EasyMock.expect(exchange.get("org.apache.cxf.management.counter.enabled")).andReturn(null);
         EasyMock.replay(exchange);
         EasyMock.replay(message);


Mime
View raw message