[CXF-7394] For CloseSequence messages that fail, log a single line warning with the rest of the stack trace at FINER
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e0ace3dc Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e0ace3dc Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e0ace3dc Branch: refs/heads/master Commit: e0ace3dc71a45a9bee6223e550f2ad869581c12d Parents: 48c28c9 Author: Daniel Kulp <[email protected]> Authored: Wed Jun 7 11:20:38 2017 -0400 Committer: Daniel Kulp <[email protected]> Committed: Wed Jun 7 12:19:23 2017 -0400 ---------------------------------------------------------------------- .../main/java/org/apache/cxf/ws/rm/Proxy.java | 50 ++++++++++++++++---- .../java/org/apache/cxf/ws/rm/ProxyTest.java | 6 ++- .../systest/ws/rm/WSRM12ServerCycleTest.java | 5 +- 3 files changed, 47 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/e0ace3dc/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 feb5a2f..e67034a 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); } } @@ -284,7 +302,14 @@ public class Proxy { } Object invoke(OperationInfo oi, ProtocolVariation protocol, - Object[] params, Map<String, Object> context, Exchange exchange) throws RMException { + 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}.", @@ -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/e0ace3dc/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 52f69b0..28cff0d 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; @@ -145,7 +146,8 @@ 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}); + 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); @@ -400,6 +402,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/e0ace3dc/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");
