You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2017/06/07 16:19:42 UTC

[1/2] cxf git commit: [CXF-7395] Allow parameters on the generic WS-A names

Repository: cxf
Updated Branches:
  refs/heads/master c7d1969c1 -> e0ace3dc7


[CXF-7395] Allow parameters on the generic WS-A names


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

Branch: refs/heads/master
Commit: 48c28c931160509a9a847f719c47a7ce54f4c030
Parents: c7d1969
Author: Daniel Kulp <dk...@apache.org>
Authored: Wed Jun 7 11:26:02 2017 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Wed Jun 7 12:19:22 2017 -0400

----------------------------------------------------------------------
 .../org/apache/cxf/ws/addressing/ContextUtils.java    | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/48c28c93/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java b/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
index 0e957f7..e1726ee 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
@@ -35,6 +35,7 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.common.jaxb.JAXBContextCache;
 import org.apache.cxf.common.jaxb.JAXBContextCache.CachedContextAndSchemas;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -283,6 +284,13 @@ public final class ContextUtils {
         relatesTo.setValue(uri);
         return relatesTo;
     }
+    
+    private static boolean startsWith(String value, String ref) {
+        if (StringUtils.isEmpty(value)) {
+            return false;
+        }
+        return value.startsWith(ref);
+    }
 
     /**
      * Helper method to determine if an EPR address is generic (either null,
@@ -294,8 +302,8 @@ public final class ContextUtils {
     public static boolean isGenericAddress(EndpointReferenceType ref) {
         return ref == null
                || ref.getAddress() == null
-               || Names.WSA_ANONYMOUS_ADDRESS.equals(ref.getAddress().getValue())
-               || Names.WSA_NONE_ADDRESS.equals(ref.getAddress().getValue());
+               || startsWith(ref.getAddress().getValue(), Names.WSA_ANONYMOUS_ADDRESS)
+               || startsWith(ref.getAddress().getValue(), Names.WSA_NONE_ADDRESS);
     }
 
     /**
@@ -308,7 +316,7 @@ public final class ContextUtils {
     public static boolean isAnonymousAddress(EndpointReferenceType ref) {
         return ref == null
                || ref.getAddress() == null
-               || Names.WSA_ANONYMOUS_ADDRESS.equals(ref.getAddress().getValue());
+               || startsWith(ref.getAddress().getValue(), Names.WSA_ANONYMOUS_ADDRESS);
     }
 
     /**


[2/2] cxf git commit: [CXF-7394] For CloseSequence messages that fail, log a single line warning with the rest of the stack trace at FINER

Posted by dk...@apache.org.
[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 <dk...@apache.org>
Authored: Wed Jun 7 11:20:38 2017 -0400
Committer: Daniel Kulp <dk...@apache.org>
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");