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 2020/01/10 16:15:52 UTC

[cxf] branch 3.3.x-fixes updated (ebdf7da -> 02a2df2)

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

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


    from ebdf7da  Recording .gitmergeinfo Changes
     new 4d7a9aa  [CXF-8189]be able to set maven-compiler-plugin source/target version seperately for different JDK
     new 65ab95f  TCK: Resolves FormParam-related failures
     new 02a2df2  Optimize a bit, close the dangling input stream

The 3 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:
 .../cxf/osgi/itests/jaxrs/JaxRsServiceTest.java    | 14 +++++++-
 .../cxf/osgi/itests/soap/HttpServiceTest.java      | 14 +++++++-
 .../cxf/osgi/itests/soap/JmsServiceTest.java       | 13 ++++++-
 osgi/karaf/features/pom.xml                        |  2 +-
 parent/pom.xml                                     |  1 +
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     | 41 +++++++++++++++++-----
 6 files changed, 72 insertions(+), 13 deletions(-)


[cxf] 01/03: [CXF-8189]be able to set maven-compiler-plugin source/target version seperately for different JDK

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

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

commit 4d7a9aa493ddd5c4b68b6eb77f7a15674cb4c502
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Jan 9 16:00:45 2020 -0500

    [CXF-8189]be able to set maven-compiler-plugin source/target version seperately for different JDK
    
    (cherry picked from commit e00fb55e8e08c25149fee72957ad8fbdaa3738f1)
---
 .../org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java | 14 +++++++++++++-
 .../org/apache/cxf/osgi/itests/soap/HttpServiceTest.java   | 14 +++++++++++++-
 .../org/apache/cxf/osgi/itests/soap/JmsServiceTest.java    | 13 ++++++++++++-
 osgi/karaf/features/pom.xml                                |  2 +-
 parent/pom.xml                                             |  1 +
 5 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
index 5f1ce8b..51bde18 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/jaxrs/JaxRsServiceTest.java
@@ -26,6 +26,7 @@ import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
+import org.apache.cxf.helpers.JavaUtils;
 import org.apache.cxf.osgi.itests.AbstractServerActivator;
 import org.apache.cxf.osgi.itests.CXFOSGiTestSupport;
 import org.osgi.framework.Constants;
@@ -112,13 +113,24 @@ public class JaxRsServiceTest extends CXFOSGiTestSupport {
     }
 
     private static InputStream serviceBundle() {
-        return TinyBundles.bundle()
+        if (JavaUtils.isJava11Compatible()) {
+            return TinyBundles.bundle()
                   .add(AbstractServerActivator.class)
                   .add(JaxRsTestActivator.class)
                   .add(Book.class)
                   .add(BookStore.class)
                   .set(Constants.BUNDLE_ACTIVATOR, JaxRsTestActivator.class.getName())
+                  .set("Require-Capability", "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=11))\"")
                   .build(TinyBundles.withBnd());
+        } else {
+            return TinyBundles.bundle()
+                .add(AbstractServerActivator.class)
+                .add(JaxRsTestActivator.class)
+                .add(Book.class)
+                .add(BookStore.class)
+                .set(Constants.BUNDLE_ACTIVATOR, JaxRsTestActivator.class.getName())
+                .build(TinyBundles.withBnd());
+        }
     }
 
 }
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
index c63f165..ab534fe 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
@@ -20,6 +20,7 @@ package org.apache.cxf.osgi.itests.soap;
 
 import java.io.InputStream;
 
+import org.apache.cxf.helpers.JavaUtils;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.osgi.itests.AbstractServerActivator;
 import org.apache.cxf.osgi.itests.CXFOSGiTestSupport;
@@ -77,13 +78,24 @@ public class HttpServiceTest extends CXFOSGiTestSupport {
     }
 
     private static InputStream serviceBundle() {
-        return TinyBundles.bundle()
+        if (JavaUtils.isJava11Compatible()) {
+            return TinyBundles.bundle()
                   .add(AbstractServerActivator.class)
                   .add(HttpTestActivator.class)
                   .add(Greeter.class)
                   .add(GreeterImpl.class)
                   .set(Constants.BUNDLE_ACTIVATOR, HttpTestActivator.class.getName())
+                  .set("Require-Capability", "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=11))\"")
                   .build(TinyBundles.withBnd());
+        } else {
+            return TinyBundles.bundle()
+                .add(AbstractServerActivator.class)
+                .add(HttpTestActivator.class)
+                .add(Greeter.class)
+                .add(GreeterImpl.class)
+                .set(Constants.BUNDLE_ACTIVATOR, HttpTestActivator.class.getName())
+                .build(TinyBundles.withBnd());
+        }
     }
 
 }
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
index 2f6e552..fbec6a8 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
@@ -24,6 +24,7 @@ import java.util.Collections;
 import javax.jms.ConnectionFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.cxf.helpers.JavaUtils;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.osgi.itests.CXFOSGiTestSupport;
 import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
@@ -82,12 +83,22 @@ public class JmsServiceTest extends CXFOSGiTestSupport {
     }
 
     private static InputStream serviceBundle() {
-        return TinyBundles.bundle()
+        if (JavaUtils.isJava11Compatible()) {
+            return TinyBundles.bundle()
                 .add(JmsTestActivator.class)
                 .add(Greeter.class)
                 .add(GreeterImpl.class)
                 .set(Constants.BUNDLE_ACTIVATOR, JmsTestActivator.class.getName())
+                .set("Require-Capability", "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=11))\"")
                 .build(TinyBundles.withBnd());
+        } else {
+            return TinyBundles.bundle()
+                .add(JmsTestActivator.class)
+                .add(Greeter.class)
+                .add(GreeterImpl.class)
+                .set(Constants.BUNDLE_ACTIVATOR, JmsTestActivator.class.getName())
+                .build(TinyBundles.withBnd());
+        }
     }
 
 }
diff --git a/osgi/karaf/features/pom.xml b/osgi/karaf/features/pom.xml
index 9875863..ef4ac49 100644
--- a/osgi/karaf/features/pom.xml
+++ b/osgi/karaf/features/pom.xml
@@ -179,7 +179,7 @@
                                 <descriptor>file:${project.build.directory}/classes/features.xml</descriptor>
                             </descriptors>
                             <distribution>org.apache.karaf.features:framework</distribution>
-                            <javase>9</javase>
+                            <javase>11</javase>
                             <framework>
                                 <feature>framework</feature>
                             </framework>
diff --git a/parent/pom.xml b/parent/pom.xml
index aa6cbf8..ccd9b4c 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -2802,6 +2802,7 @@
 	    <id>java9-plus</id>
 	    <properties>
                 <org.apache.cxf.transport.websocket.atmosphere.disabled>true</org.apache.cxf.transport.websocket.atmosphere.disabled>
+                <cxf.jdk.version>11</cxf.jdk.version>
 	    </properties>
 	    <activation>
         	<jdk>[9,)</jdk>


[cxf] 03/03: Optimize a bit, close the dangling input stream

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

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

commit 02a2df2dca1d5c19d682beb33d90d01cbb036433
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Fri Jan 10 11:10:49 2020 -0500

    Optimize a bit, close the dangling input stream
    
    (cherry picked from commit 42ae16e8fafcb172e28c481e3052a40e5e5108fb)
---
 .../main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java   | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 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 9eeb4ab..61ec6e4 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
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.jaxrs.utils;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -92,6 +90,7 @@ import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CacheAndWriteOutputStream;
 import org.apache.cxf.io.ReaderInputStream;
@@ -1893,14 +1892,13 @@ public final class JAXRSUtils {
 
     // copy the input stream so that it is not inadvertently closed
     private static InputStream copyAndGetEntityStream(Message m) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        try {
-            IOUtils.copy(m.getContent(InputStream.class), baos);
+        LoadingByteArrayOutputStream baos = new LoadingByteArrayOutputStream(); 
+        try (InputStream in = m.getContent(InputStream.class)) {
+            IOUtils.copy(in, baos);
         } catch (IOException e) {
             throw ExceptionUtils.toInternalServerErrorException(e, null);
         }
-        final byte[] copiedBytes = baos.toByteArray();
-        m.setContent(InputStream.class, new ByteArrayInputStream(copiedBytes));
-        return new ByteArrayInputStream(copiedBytes);
+        m.setContent(InputStream.class, baos.createInputStream());
+        return baos.createInputStream();
     }
 }


[cxf] 02/03: TCK: Resolves FormParam-related failures

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

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

commit 65ab95fedfd1d5c396315e1efecbd6e60c96183d
Author: Andy McCright <j....@gmail.com>
AuthorDate: Sat Jan 4 19:48:21 2020 -0600

    TCK: Resolves FormParam-related failures
    
    Should fix:
    allParamsInParamTest_from_standalone
    allParamsOnFieldTest_from_standalone
    formParamInParamTest_from_standalone
    formParamOnFieldTest_from_standalone
    
    Signed-off-by: Andy McCright <j....@gmail.com>
    (cherry picked from commit dc71ce1635330136e472e0b6fb5ce4a71ae0d474)
---
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     | 43 +++++++++++++++++-----
 1 file changed, 34 insertions(+), 9 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 9e6154c..9eeb4ab 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
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.jaxrs.utils;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -89,6 +91,7 @@ import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CacheAndWriteOutputStream;
 import org.apache.cxf.io.ReaderInputStream;
@@ -863,14 +866,6 @@ public final class JAXRSUtils {
                                                       OperationResourceInfo ori)
         throws IOException, WebApplicationException {
 
-        InputStream is = message.getContent(InputStream.class);
-        if (is == null) {
-            Reader reader = message.getContent(Reader.class);
-            if (reader != null) {
-                is = new ReaderInputStream(reader);
-            }
-        }
-
         if (parameterClass == AsyncResponse.class) {
             return new AsyncResponseImpl(message);
         }
@@ -882,6 +877,23 @@ public final class JAXRSUtils {
             contentType = defaultCt == null ? MediaType.APPLICATION_OCTET_STREAM : defaultCt;
         }
 
+        MessageContext mc = new MessageContextImpl(message);
+        MediaType mt = mc.getHttpHeaders().getMediaType();
+
+        InputStream is;
+        if (mt == null || mt.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
+            is = copyAndGetEntityStream(message);
+        } else {
+            is = message.getContent(InputStream.class);
+        }
+
+        if (is == null) {
+            Reader reader = message.getContent(Reader.class);
+            if (reader != null) {
+                is = new ReaderInputStream(reader);
+            }
+        }
+
         return readFromMessageBody(parameterClass,
                                    parameterType,
                                    parameterAnns,
@@ -1018,8 +1030,9 @@ public final class JAXRSUtils {
             m.put(FormUtils.FORM_PARAM_MAP, params);
 
             if (mt == null || mt.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
+                InputStream entityStream = copyAndGetEntityStream(m);
                 String enc = HttpUtils.getEncoding(mt, StandardCharsets.UTF_8.name());
-                String body = FormUtils.readBody(m.getContent(InputStream.class), enc);
+                String body = FormUtils.readBody(entityStream, enc);
                 FormUtils.populateMapFromStringOrHttpRequest(params, m, body, enc, decode);
             } else {
                 if ("multipart".equalsIgnoreCase(mt.getType())
@@ -1878,4 +1891,16 @@ public final class JAXRSUtils {
         return errorMessage;
     }
 
+    // copy the input stream so that it is not inadvertently closed
+    private static InputStream copyAndGetEntityStream(Message m) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            IOUtils.copy(m.getContent(InputStream.class), baos);
+        } catch (IOException e) {
+            throw ExceptionUtils.toInternalServerErrorException(e, null);
+        }
+        final byte[] copiedBytes = baos.toByteArray();
+        m.setContent(InputStream.class, new ByteArrayInputStream(copiedBytes));
+        return new ByteArrayInputStream(copiedBytes);
+    }
 }