You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2020/11/11 01:33:25 UTC

[cxf] branch 3.4.x-fixes updated (f993b8c -> 19b6ca0)

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

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


    from f993b8c  Setup merge tracking
     new b92ef8b  CXF-8356: JAXRS Multipart-Handling broken for InputStream/Datasource parameters (#719)
     new 067f1af  Update to Brave 5.13.0 / Zipkin 2.22.1 / Reporter 2.15.4
     new c01e880  Update to Spring Framework 5.2.11.RELEASE
     new 19b6ca0  Recording .gitmergeinfo Changes

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:
 .gitmergeinfo                                      |  1 -
 parent/pom.xml                                     |  8 +-
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     | 11 ++-
 .../jaxrs/JAXRSMultipartLocalTransportTest.java    | 88 ++++++++++++++++++++++
 .../apache/cxf/systest/jaxrs/MultipartStore.java   | 18 +++++
 5 files changed, 118 insertions(+), 8 deletions(-)
 create mode 100644 systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartLocalTransportTest.java


[cxf] 01/04: CXF-8356: JAXRS Multipart-Handling broken for InputStream/Datasource parameters (#719)

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

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

commit b92ef8b4c593ff2f35bd9b8a827970499d489783
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Tue Nov 3 18:23:45 2020 -0500

    CXF-8356: JAXRS Multipart-Handling broken for InputStream/Datasource parameters (#719)
    
    (cherry picked from commit c8c2202136ad0b9174c9a21ac3dfa7fc471347f0)
---
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     | 11 ++-
 .../jaxrs/JAXRSMultipartLocalTransportTest.java    | 88 ++++++++++++++++++++++
 .../apache/cxf/systest/jaxrs/MultipartStore.java   | 18 +++++
 3 files changed, 114 insertions(+), 3 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 df314d2..0518d69 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
@@ -876,11 +876,16 @@ public final class JAXRSUtils {
             contentType = defaultCt == null ? MediaType.APPLICATION_OCTET_STREAM : defaultCt;
         }
 
-        MessageContext mc = new MessageContextImpl(message);
+        final MediaType contentTypeMt = toMediaType(contentType);
+        final MessageContext mc = new MessageContextImpl(message);
+
         MediaType mt = mc.getHttpHeaders().getMediaType();
+        if (mt == null) {
+            mt = contentTypeMt;
+        }
 
         InputStream is;
-        if (mt == null || mt.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
+        if (mt.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
             is = copyAndGetEntityStream(message);
         } else {
             is = message.getContent(InputStream.class);
@@ -897,7 +902,7 @@ public final class JAXRSUtils {
                                    parameterType,
                                    parameterAnns,
                                    is,
-                                   toMediaType(contentType),
+                                   contentTypeMt,
                                    ori,
                                    message);
     }
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartLocalTransportTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartLocalTransportTest.java
new file mode 100644
index 0000000..5d74dd9
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartLocalTransportTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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.jaxrs;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class JAXRSMultipartLocalTransportTest {
+    private static final String ENDPOINT_ADDRESS = "local://test-multipart";
+    private static final String TEMPLATE = "{ "
+        + "\"id\": %s, "
+        + "\"name\": \"Book #%s\", "
+        + "\"class\": \"org.apache.cxf.systest.jaxrs.Book\" }";
+    private static Server server;
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        sf.setResourceClasses(MultipartStore.class);
+        sf.setResourceProvider(MultipartStore.class, new SingletonResourceProvider(new MultipartStore(), true));
+        sf.setAddress(ENDPOINT_ADDRESS);
+        server = sf.create();
+    }
+    
+    @AfterClass
+    public static void stopServers() throws Exception {
+        if (server != null) {
+            server.stop();
+            server.destroy();
+        }
+    }
+
+    @Test
+    public void testBookAsMultipleInputStreams() throws Exception {
+        final MultipartStore store = JAXRSClientFactory.create(ENDPOINT_ADDRESS, MultipartStore.class, 
+            Collections.singletonList(new JacksonJaxbJsonProvider()));
+        
+        final byte[] books1 = generateBooks(40000).getBytes(StandardCharsets.UTF_8); 
+        final byte[] books2 = generateBooks(2000).getBytes(StandardCharsets.UTF_8);
+        
+        final List<Book> books = store.addBookJsonTypeFromStreams(new ByteArrayInputStream(books1), 
+            new ByteArrayInputStream(books2));
+        
+        assertThat(books.size(), equalTo(42000));
+    }
+
+    private String generateBooks(int size) {
+        return "[" + IntStream
+            .range(0, size)
+            .mapToObj(id -> String.format(TEMPLATE, id, id))
+            .collect(Collectors.joining(",")) + "]";
+    }
+}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
index a1a7c60..b9c244b 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
@@ -23,10 +23,13 @@ package org.apache.cxf.systest.jaxrs;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
@@ -49,6 +52,8 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
@@ -493,6 +498,19 @@ public class MultipartStore {
         b1.setId(124);
         return Response.ok(b1).build();
     }
+    
+    @POST
+    @Path("/books/jsonstream")
+    @Produces("text/xml")
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    public List<Book> addBookJsonTypeFromStreams(
+            @Multipart(value = "part1", type = "application/octet-stream") InputStream in1,
+            @Multipart(value = "part2", type = "application/octet-stream") InputStream in2) throws Exception {
+        final ObjectMapper mapper = new ObjectMapper();
+        final Book[] array1 = mapper.readValue(in1, Book[].class);
+        final Book[] array2 = mapper.readValue(in2, Book[].class);
+        return Stream.concat(Arrays.stream(array1), Arrays.stream(array2)).collect(Collectors.toList());
+    }
 
     @POST
     @Path("/books/filesform")


[cxf] 04/04: Recording .gitmergeinfo Changes

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

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

commit 19b6ca0089a923dfb1f7f50c4ed09376f47dcb53
Author: reta <dr...@gmail.com>
AuthorDate: Tue Nov 10 20:26:07 2020 -0500

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index be8e0c6..152010a 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -1,3 +1,2 @@
 origin/master
 
-


[cxf] 03/04: Update to Spring Framework 5.2.11.RELEASE

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

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

commit c01e88091015218ad2711dbee70675cdf833748a
Author: reta <dr...@gmail.com>
AuthorDate: Tue Nov 10 20:14:09 2020 -0500

    Update to Spring Framework 5.2.11.RELEASE
    
    (cherry picked from commit 940c3d58c109a5dd3bfb756e1a5d15b2558fbb1b)
---
 parent/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 066bc67..4d23695 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -199,7 +199,7 @@
         <cxf.spring.mock>spring-test</cxf.spring.mock>
         <cxf.spring.osgi.version>1.2.1</cxf.spring.osgi.version>
         <cxf.spring.security.version>5.3.5.RELEASE</cxf.spring.security.version>
-        <cxf.spring.version>5.2.9.RELEASE</cxf.spring.version>
+        <cxf.spring.version>5.2.11.RELEASE</cxf.spring.version>
         <cxf.stax-ex.version>1.8.3</cxf.stax-ex.version>
         <cxf.swagger.ui.version>3.32.1</cxf.swagger.ui.version>
         <cxf.swagger.v3.version>2.1.5</cxf.swagger.v3.version>


[cxf] 02/04: Update to Brave 5.13.0 / Zipkin 2.22.1 / Reporter 2.15.4

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

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

commit 067f1afd5e29c0b6601a6df0e44862f52e548476
Author: reta <dr...@gmail.com>
AuthorDate: Wed Nov 4 19:12:55 2020 -0500

    Update to Brave 5.13.0 / Zipkin 2.22.1 / Reporter 2.15.4
    
    (cherry picked from commit fb4b78dbc40ff9b56eb53abe3aca02865ef8672d)
---
 parent/pom.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 3e31dc2..066bc67 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -86,9 +86,9 @@
         <cxf.atmosphere.version.range>[2.4,3.0)</cxf.atmosphere.version.range>
         <cxf.atmosphere.version>2.6.1</cxf.atmosphere.version>
         <cxf.bcprov.version>1.66</cxf.bcprov.version>
-        <cxf.brave.reporter.version>2.15.2</cxf.brave.reporter.version>
-        <cxf.brave.version>5.12.6</cxf.brave.version>
-        <cxf.brave.zipkin.version>2.21.7</cxf.brave.zipkin.version>
+        <cxf.brave.reporter.version>2.15.4</cxf.brave.reporter.version>
+        <cxf.brave.version>5.13.0</cxf.brave.version>
+        <cxf.brave.zipkin.version>2.22.1</cxf.brave.zipkin.version>
         <cxf.cda.api.osgi.range>[1.1,2)</cxf.cda.api.osgi.range>
         <cxf.cdi.api.version>2.0.2</cxf.cdi.api.version>
         <cxf.classgraph.version>4.8.25</cxf.classgraph.version>