You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2020/08/27 17:24:55 UTC

[cxf] branch 3.3.x-fixes updated (61328c9 -> a67732d)

This is an automated email from the ASF dual-hosted git repository.

ffang pushed a change to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 61328c9  Recording .gitmergeinfo Changes
     new 31ba36d  [CXF-8287]HttpConduit: Also set org.apache.cxf.transport.service_not_available for status code 429
     new 5cc7a89  [CXF-8285]adding a test to demonstrate how to specify an xml adapter for jaxb marshal/unmarshal
     new e43abf2  [CXF-8332]JDK15 support
     new a67732d  [CXF-8329] avoid NPE with empty query parameters

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     |   6 +-
 .../org/apache/cxf/jaxrs/impl/UriInfoImplTest.java |  13 +++
 .../org/apache/cxf/transport/http/HTTPConduit.java |   2 +-
 .../transport/jms/util/MessageListenerTest.java    |   4 +-
 .../cxf/systest/dispatch/WsaMessageIdTest.java     | 128 +++++++++++++++++++++
 .../addressing/StringTrimAdapter.java}             |  17 +--
 .../org/apache/cxf/ws/addressing/package-info.java |  10 +-
 7 files changed, 162 insertions(+), 18 deletions(-)
 create mode 100644 systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/WsaMessageIdTest.java
 copy systests/jaxws/src/test/java/org/apache/cxf/{systest/jaxws/cxf5064/HeaderObjTypeAdapter.java => ws/addressing/StringTrimAdapter.java} (73%)
 copy distribution/src/main/release/samples/java_first_jaxws/src/main/java/demo/hw/server/User.java => systests/jaxws/src/test/java/org/apache/cxf/ws/addressing/package-info.java (86%)


[cxf] 04/04: [CXF-8329] avoid NPE with empty query parameters

Posted by ff...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit a67732dc5163ba35ac178a79ac124e773b4a8ce6
Author: Jens Kleine-Herzbruch <je...@dzbank.de>
AuthorDate: Tue Aug 25 11:32:03 2020 +0200

    [CXF-8329] avoid NPE with empty query parameters
    
    (cherry picked from commit ae805e6f6b78d9a4e44fdc42750edc2997b0b39c)
---
 .../main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java    |  6 ++++--
 .../java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java     | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 61ec6e4..e6ef31d 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -1326,8 +1326,10 @@ public final class JAXRSUtils {
                     value = index < part.length() ? part.substring(index + 1) : "";
                 }
                 if (valueIsCollection) {
-                    for (String s : value.split(",")) {
-                        addStructuredPartToMap(queries, sep, name, s, decode, decodePlus);
+                    if (value != null) {
+                        for (String s : value.split(",")) {
+                            addStructuredPartToMap(queries, sep, name, s, decode, decodePlus);
+                        }
                     }
                 } else {
                     addStructuredPartToMap(queries, sep, name, value, decode, decodePlus);
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java
index f8a3f46..fe07689 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java
@@ -301,6 +301,19 @@ public class UriInfoImplTest {
         assertEquals("Wrong query value", qps.get("n").get(1), "3");
         assertEquals("Wrong query value", qps.get("b").get(0), "2");
         assertEquals("Wrong query value", qps.get("a.b").get(0), "ab");
+
+        Message m = mockMessage("http://localhost:8080/baz", "/bar",
+                "N=0&n=1%202&n=3&&b=2&a%2Eb=ab");
+        m.put("parse.query.value.as.collection", Boolean.TRUE);
+        u = new UriInfoImpl(m, null);
+
+        qps = u.getQueryParameters();
+        assertEquals("Number of queries is wrong", 4, qps.size());
+        assertEquals("Wrong query value", qps.get("N").get(0), "0");
+        assertEquals("Wrong query value", qps.get("n").get(0), "1 2");
+        assertEquals("Wrong query value", qps.get("n").get(1), "3");
+        assertEquals("Wrong query value", qps.get("b").get(0), "2");
+        assertEquals("Wrong query value", qps.get("a.b").get(0), "ab");
     }
 
     @Test


[cxf] 02/04: [CXF-8285]adding a test to demonstrate how to specify an xml adapter for jaxb marshal/unmarshal

Posted by ff...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 5cc7a890a4530eea0890d40c6eedb10235cf6d20
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Aug 6 17:07:08 2020 -0400

    [CXF-8285]adding a test to demonstrate how to specify an xml adapter for jaxb marshal/unmarshal
    
    (cherry picked from commit 11df55ce77572b4dc865ff7166784139dac5b3f8)
---
 .../cxf/systest/dispatch/WsaMessageIdTest.java     | 128 +++++++++++++++++++++
 .../cxf/ws/addressing/StringTrimAdapter.java       |  38 ++++++
 .../org/apache/cxf/ws/addressing/package-info.java |  25 ++++
 3 files changed, 191 insertions(+)

diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/WsaMessageIdTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/WsaMessageIdTest.java
new file mode 100644
index 0000000..7f5bf42
--- /dev/null
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/WsaMessageIdTest.java
@@ -0,0 +1,128 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.dispatch;
+
+
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.UnmarshalException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+
+import org.xml.sax.SAXException;
+
+import org.apache.cxf.ws.addressing.AttributedURIType;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class WsaMessageIdTest {
+
+    /*
+     * 3.1.4 White Space Normalization during Validation preserve No normalization is done, the value is the
+     * ·normalized value· replace All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are
+     * replaced > with #x20 (space). collapse Subsequent to the replacements specified above under replace,
+     * contiguous sequences of #x20s are collapsed to a single #x20, and initial and/or final #x20s are
+     * deleted.
+     */
+    @Test
+    public void testCollapseNeeded() throws JAXBException, SAXException {
+        for (String[] value : new String[][] {
+            {
+                "expected", " expected"
+            }, {
+                "expected", " expected "
+            }, {
+                "expected", " expected  "
+            }, {
+                "expected", "  expected"
+            }, {
+                "expected", "  expected  "
+            }, {
+                "expected expected", "  expected         expected"
+            },
+        }) {
+            String expected = value[0];
+            String actual = value[1];
+            assertEquals("|" + expected + "|", "|" + unmarshalMessageIDValue(actual) + "|");
+        }
+    }   
+
+    @Test
+    public void testNoCollapseNeeded() throws JAXBException, SAXException {
+        for (String value : Arrays.asList("", "http://cxf.com", "mailto:info@kimholland.nl",
+                                          "../%C3%A9dition.html", "../édition.html",
+                                          "http://corona.com/prod.html#shirt", "../prod.html#shirt",
+                                          "urn:example:org")) {
+            assertEquals(value, unmarshalMessageIDValue(value));
+        }
+    }
+
+    @Test
+    public void testSchemaValidationEnabled() throws JAXBException, SAXException {
+        try {
+            unmarshalMessageIDValue("##");
+            fail();
+        } catch (UnmarshalException cause) {
+            assertTrue(cause.getLinkedException().getMessage()
+                .contains("'##' is not a valid value for 'anyURI'"));
+        }
+    }
+
+    private String unmarshalMessageIDValue(String messageIDValue) throws JAXBException, SAXException {
+        String xmlString = "<MessageID xmlns=\"http://www.w3.org/2005/08/addressing\">" + messageIDValue
+                           + "</MessageID>";
+
+        // Create unmarshaller
+        JAXBContext jc = JAXBContext.newInstance("org.apache.cxf.ws.addressing");
+        Unmarshaller unmarshaller = jc.createUnmarshaller();
+        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        URL wsAddrXsd = getClass().getResource("/schemas/wsdl/ws-addr.xsd");
+        assertNotNull(wsAddrXsd);
+
+        // Enable schema validation
+        Schema schema = sf.newSchema(wsAddrXsd);
+        unmarshaller.setSchema(schema);
+        
+        //unmarshaller.setAdapter(new StringTrimAdapter());
+        // Unmarshal the MessageID XML-fragment
+        JAXBElement je = (JAXBElement)unmarshaller.unmarshal(new StringReader(xmlString));
+        assertEquals(AttributedURIType.class, je.getDeclaredType());
+        assertTrue(je.getValue() instanceof AttributedURIType);
+        AttributedURIType attributedURIType = (AttributedURIType)je.getValue();
+
+        // Return unmarshalled value
+        return attributedURIType.getValue();
+    }
+
+    
+}
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/ws/addressing/StringTrimAdapter.java b/systests/jaxws/src/test/java/org/apache/cxf/ws/addressing/StringTrimAdapter.java
new file mode 100644
index 0000000..d117e32
--- /dev/null
+++ b/systests/jaxws/src/test/java/org/apache/cxf/ws/addressing/StringTrimAdapter.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.addressing;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+public class StringTrimAdapter extends XmlAdapter<String, String> {
+    @Override
+    public String unmarshal(String v) throws Exception {
+        if (v == null) {
+            return null;
+        }
+        return v.trim().replaceAll("\\s+", " ");
+    }
+    @Override
+    public String marshal(String v) throws Exception {
+        if (v == null) {
+            return null;
+        }
+        return v.trim();
+    }
+}
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/ws/addressing/package-info.java b/systests/jaxws/src/test/java/org/apache/cxf/ws/addressing/package-info.java
new file mode 100644
index 0000000..563e17f
--- /dev/null
+++ b/systests/jaxws/src/test/java/org/apache/cxf/ws/addressing/package-info.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+@XmlJavaTypeAdapter(value = StringTrimAdapter.class,
+                    type = String.class)
+package org.apache.cxf.ws.addressing;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+


[cxf] 03/04: [CXF-8332]JDK15 support

Posted by ff...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit e43abf2117d1575ac9618366acfffabf4aac377b
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Aug 27 10:16:33 2020 -0400

    [CXF-8332]JDK15 support
    
    (cherry picked from commit 4b26fa366b98fe1165037d1e295f03ab44d721e4)
---
 .../java/org/apache/cxf/transport/jms/util/MessageListenerTest.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java
index d6828e1..1030c68 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/util/MessageListenerTest.java
@@ -42,6 +42,7 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 public class MessageListenerTest {
 
@@ -88,7 +89,8 @@ public class MessageListenerTest {
         JMSException ex = exListener.exception;
         assertNotNull(ex);
         // Closing the pooled connection will result in a NPE when using it
-        assertEquals("Wrapped exception. null", ex.getMessage());
+        assertTrue(ex.getMessage().contains("Wrapped exception.") 
+                   && ex.getMessage().contains("null"));
     }
 
     @Test


[cxf] 01/04: [CXF-8287]HttpConduit: Also set org.apache.cxf.transport.service_not_available for status code 429

Posted by ff...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 31ba36d8debc16bd440799a5c7c11c76a3c86c05
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Aug 6 11:19:45 2020 -0400

    [CXF-8287]HttpConduit: Also set org.apache.cxf.transport.service_not_available for status code 429
    
    (cherry picked from commit 7bcba1ed4155f21e9cf5a4ff85f953ba712ca217)
---
 .../http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index a4d7193..8e3b132 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -1600,7 +1600,7 @@ public abstract class HTTPConduit
             }
             if (exchange != null) {
                 exchange.put(Message.RESPONSE_CODE, rc);
-                if (rc == 404 || rc == 503) {
+                if (rc == 404 || rc == 503 || rc == 429) {
                     exchange.put("org.apache.cxf.transport.service_not_available", true);
                 }
             }