cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [7/9] cxf git commit: [CXF-7394] For CloseSequence messages that fail, log a single line warning with the rest of the stack trace at FINER
Date Wed, 07 Jun 2017 17:54:13 GMT
[CXF-7394] For CloseSequence messages that fail, log a single line warning with the rest of
the stack trace at FINER

# Conflicts:
#	rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
#	rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java


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

Branch: refs/heads/3.1.x-fixes
Commit: 66cc4bec2ee6919be056054ab4803fc0f9c42a9c
Parents: 6735dd0
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Jun 7 11:20:38 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Jun 7 12:44:25 2017 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/cxf/ws/rm/Proxy.java   | 58 +++++++++++++++-----
 .../java/org/apache/cxf/ws/rm/ProxyTest.java    |  8 ++-
 .../systest/ws/rm/WSRM12ServerCycleTest.java    |  5 +-
 3 files changed, 52 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/66cc4bec/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
index eb8d55b..117561c 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.ws.rm;
 
+import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -35,6 +36,8 @@ import org.apache.cxf.endpoint.ClientImpl;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.DeferredConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.logging.FaultListener;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -235,13 +238,28 @@ public class Proxy {
                 Collections.singletonMap(SourceSequence.class.getName(), 
                                          (Object)s));
 
-        if (constants instanceof RM11Constants) {
-            CloseSequenceType csr = new CloseSequenceType();
-            csr.setIdentifier(s.getIdentifier());
-            csr.setLastMsgNumber(s.getCurrentMessageNr());
-            invoke(oi, protocol, new Object[] {csr}, context);
-        } else {
-            invoke(oi, protocol, new Object[] {}, context);
+        context.put(FaultListener.class.getName(), new FaultListener() {
+            public boolean faultOccurred(Exception exception, String description, Message
message) {
+                if (exception.getCause() instanceof IOException) {
+                    //for close messages, the server may be gone and nothing we can do so
don't pollute the logs
+                    LOG.log(Level.WARNING, "Could not send CloseSequence message: " 
+                            + exception.getCause().getMessage());
+                    return false;
+                }
+                return true;
+            }
+        });
+        try {
+            if (constants instanceof RM11Constants) {
+                CloseSequenceType csr = new CloseSequenceType();
+                csr.setIdentifier(s.getIdentifier());
+                csr.setLastMsgNumber(s.getCurrentMessageNr());
+                invoke(oi, protocol, new Object[] {csr}, context, Level.FINER);
+            } else {
+                invoke(oi, protocol, new Object[] {}, context, Level.FINER);
+            }
+        } catch (Fault f) {
+            throw new RMException(f);
         }
     }
     
@@ -282,10 +300,17 @@ public class Proxy {
             offeredIdentifier = offer.getIdentifier();
         }
     }
-       
-    Object invoke(OperationInfo oi, ProtocolVariation protocol, 
-                  Object[] params, Map<String, Object> context, Exchange exchange)
throws RMException {
-        
+
+    Object invoke(OperationInfo oi, ProtocolVariation protocol,
+                  Object[] params, Map<String, Object> context, 
+                  Exchange exchange) throws RMException {
+        return invoke(oi, protocol, params, context, exchange, Level.SEVERE);
+    }
+    Object invoke(OperationInfo oi, ProtocolVariation protocol,
+                  Object[] params, Map<String, Object> context, 
+                  Exchange exchange,
+                  Level exceptionLevel) throws RMException {
+
         if (LOG.isLoggable(Level.INFO)) {
             LOG.log(Level.INFO, "Sending out-of-band RM protocol message {0}.", 
                     oi == null ? null : oi.getName());
@@ -325,7 +350,7 @@ public class Proxy {
             org.apache.cxf.common.i18n.Message msg = 
                 new org.apache.cxf.common.i18n.Message("SEND_PROTOCOL_MSG_FAILED_EXC", LOG,

                                                        oi == null ? null : oi.getName());
-            LOG.log(Level.SEVERE, msg.toString(), ex);
+            LOG.log(exceptionLevel, msg.toString(), ex);
             throw new RMException(msg, ex);
         }
         return null;
@@ -333,9 +358,14 @@ public class Proxy {
     
     Object invoke(OperationInfo oi, ProtocolVariation protocol, Object[] params, Map<String,
Object> context)
         throws RMException {
-        return invoke(oi, protocol, params, context, new ExchangeImpl());
+        return invoke(oi, protocol, params, context, Level.SEVERE);
+    }
+
+    Object invoke(OperationInfo oi, ProtocolVariation protocol, Object[] params, 
+                  Map<String, Object> context, Level level)
+        throws RMException {
+        return invoke(oi, protocol, params, context, new ExchangeImpl(), level);
     }
-    
     Object invoke(OperationInfo oi, ProtocolVariation protocol, Object[] params) throws RMException
{
         return invoke(oi, protocol, params, null);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/66cc4bec/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
index c310d9c..74fd6e2 100644
--- a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
+++ b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
@@ -22,6 +22,7 @@ package org.apache.cxf.ws.rm;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Level;
 
 import javax.xml.datatype.Duration;
 
@@ -144,8 +145,9 @@ public class ProxyTest extends Assert {
     
     @Test
     public void testLastMessage() throws NoSuchMethodException, RMException {
-        Method m = Proxy.class.getDeclaredMethod("invoke", 
-            new Class[] {OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class});
+        Method m = Proxy.class.getDeclaredMethod("invoke",
+            new Class[] {OperationInfo.class, ProtocolVariation.class, Object[].class,
+                         Map.class, Level.class});
         Proxy proxy = EasyMock.createMockBuilder(Proxy.class)
             .addMockedMethod(m).createMock(control);
         proxy.setReliableEndpoint(rme);
@@ -399,6 +401,6 @@ public class ProxyTest extends Assert {
         throws RMException {
         EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(ProtocolVariation.class),
             EasyMock.isA(Object[].class),
-            EasyMock.isA(Map.class))).andReturn(expectedReturn).anyTimes();
+            EasyMock.isA(Map.class), EasyMock.same(Level.FINER))).andReturn(expectedReturn).anyTimes();
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/66cc4bec/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
index 64e0b64..8a4a5d8 100644
--- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
+++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
@@ -35,6 +35,7 @@ import org.apache.cxf.greeter_control.GreeterService;
 import org.apache.cxf.systest.ws.util.ConnectionHelper;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.rm.RM11Constants;
 import org.apache.cxf.ws.rm.RMManager;
 import org.apache.cxf.ws.rm.feature.RMFeature;
 import org.apache.cxf.ws.rm.manager.AcksPolicyType;
@@ -128,7 +129,7 @@ public class WSRM12ServerCycleTest extends AbstractBusClientServerTestBase
{
         RMFeature feature = new RMFeature();
         feature.setRMAssertion(rmAssertion);
         feature.setDestinationPolicy(destinationPolicy);
-        //feature.setRMNamespace(RM11Constants.NAMESPACE_URI);
+        feature.setRMNamespace(RM11Constants.NAMESPACE_URI);
 
         return feature;
     }
@@ -165,7 +166,7 @@ public class WSRM12ServerCycleTest extends AbstractBusClientServerTestBase
{
 
 
         control.stopGreeter(CFG);
-        control.startGreeter(CFG);
+        //control.startGreeter(CFG);
         
         // this will cause an exception as the sequence is no longer valid
         //greeter.greetMe("four");


Mime
View raw message