You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/09/10 15:59:23 UTC

[cxf] branch 3.2.x-fixes updated (858b99a -> 5728deb)

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

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


    from 858b99a  [CXF-7833]enable configuration to expire jetty session
     new 0ef0ee6  CXF-7332 - JAXRS Client API doesnt support lambda
     new 8f3d253  [CXF-7808] Ensure injectThroughMethod reports its error in the log otherwise it just swallows the error for end user
     new 5728deb  Fixing previous commit

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:
 .../org/apache/cxf/jaxrs/utils/InjectionUtils.java |  2 +
 .../cxf/jaxrs/client/ClientProviderFactory.java    |  4 ++
 .../systest/jaxrs/JAXRS20ClientServerBookTest.java | 45 ++++++++++++++++++++--
 3 files changed, 48 insertions(+), 3 deletions(-)


[cxf] 02/03: [CXF-7808] Ensure injectThroughMethod reports its error in the log otherwise it just swallows the error for end user

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

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

commit 8f3d2532e403e3c30d607406a9f8f1198a8ebcf0
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Fri Sep 7 14:53:50 2018 +0200

    [CXF-7808] Ensure injectThroughMethod reports its error in the log otherwise it just swallows the error for end user
    
    (cherry picked from commit a553c4215337e0bfb8d6d5a394d601102df65711)
---
 .../jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java  | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index d6b1277..eb570fd 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -49,6 +49,7 @@ import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.ws.rs.WebApplicationException;
@@ -366,6 +367,7 @@ public final class InjectionUtils {
         } catch (IllegalAccessException ex) {
             reportServerError("METHOD_ACCESS_FAILURE", method.getName());
         } catch (InvocationTargetException ex) {
+            LOG.severe(ex.getCause().getMessage(), ex.getCause());
             Response r = JAXRSUtils.convertFaultToResponse(ex.getCause(), inMessage);
             if (r != null) {
                 inMessage.getExchange().put(Response.class, r);


[cxf] 03/03: Fixing previous commit

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

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

commit 5728deb82e856b4b795ce52b4adcc616e0e3b928
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Fri Sep 7 14:56:28 2018 +0200

    Fixing previous commit
    
    (cherry picked from commit e95413cbafbfa23fd2c82f6009166cd398e9caa6)
---
 .../jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index eb570fd..cee4a59 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -367,7 +367,7 @@ public final class InjectionUtils {
         } catch (IllegalAccessException ex) {
             reportServerError("METHOD_ACCESS_FAILURE", method.getName());
         } catch (InvocationTargetException ex) {
-            LOG.severe(ex.getCause().getMessage(), ex.getCause());
+            LOG.log(Level.SEVERE, ex.getCause().getMessage(), ex);
             Response r = JAXRSUtils.convertFaultToResponse(ex.getCause(), inMessage);
             if (r != null) {
                 inMessage.getExchange().put(Response.class, r);


[cxf] 01/03: CXF-7332 - JAXRS Client API doesnt support lambda

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

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

commit 0ef0ee6c79738fb521ef02c39dad9b545f959d4a
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Mon Sep 10 16:13:08 2018 +0100

    CXF-7332 - JAXRS Client API doesnt support lambda
    
    (cherry picked from commit 84a6fb5de9a324b5f79b2358cf6f4ed7d562333a)
---
 .../cxf/jaxrs/client/ClientProviderFactory.java    |  4 ++
 .../systest/jaxrs/JAXRS20ClientServerBookTest.java | 45 ++++++++++++++++++++--
 2 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
index 8807f99..8100309 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProviderFactory.java
@@ -74,6 +74,10 @@ public final class ClientProviderFactory extends ProviderFactory {
         super.setCommonProviders(theProviders);
         for (ProviderInfo<? extends Object> provider : theProviders) {
             Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider.getProvider());
+            if (providerCls == Object.class) {
+                // If the provider is a lambda, ClassHelper.getRealClass returns Object.class
+                providerCls = provider.getProvider().getClass();
+            }
             if (filterContractSupported(provider, providerCls, ClientRequestFilter.class)) {
                 addProviderToList(clientRequestFilters, provider);
             }
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index f3b37a8..d2bc099 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -119,7 +119,7 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
         Book book = echoEndpointTarget.request().accept("text/xml").get(Book.class);
         assertEquals(1023L, book.getId());
     }
-    
+
     @Test
     public void testGetGenericBook() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/genericbooks/123";
@@ -281,7 +281,7 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
                      response.getHeaderString("ServerWriterInterceptorHttpResponse"));
         assertEquals("text/plain;charset=us-ascii", response.getMediaType().toString());
     }
-    
+
     @Test
     public void testPreMatchContainerFilterThrowsIOException() {
         String address = "http://localhost:" + PORT + "/throwExceptionIO";
@@ -720,6 +720,28 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
     }
 
     @Test
+    public void testClientFiltersLocalResponseLambdas() {
+        String address = "http://localhost:" + PORT + "/bookstores";
+        List<Object> providers = new ArrayList<>();
+
+        providers.add((ClientRequestFilter) ctx -> {
+            ctx.abortWith(Response.status(201).entity(ctx.getEntity()).type(MediaType.TEXT_XML_TYPE).build());
+        });
+
+        providers.add((ClientResponseFilter) (reqContext, respContext) -> {
+            MultivaluedMap<String, String> headers = respContext.getHeaders();
+            headers.putSingle(HttpHeaders.LOCATION, "http://localhost/redirect");
+        });
+        WebClient wc = WebClient.create(address, providers);
+        Book theBook = new Book("Echo", 123L);
+        Response r = wc.post(theBook);
+        assertEquals(201, r.getStatus());
+        assertEquals("http://localhost/redirect", r.getHeaderString(HttpHeaders.LOCATION));
+        Book responseBook = r.readEntity(Book.class);
+        assertSame(theBook, responseBook);
+    }
+
+    @Test
     public void testPostBook() {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
         WebClient wc = createWebClientPost(address);
@@ -834,7 +856,7 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
                     ExceptionUtils.getRootCause(e) instanceof UnknownHostException);
         }
     }
-    
+
     @Test
     public void testGetSetEntityStream() {
         String address = "http://localhost:" + PORT + "/bookstore/entityecho";
@@ -856,6 +878,23 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
         assertEquals(entity, response.readEntity(String.class));
     }
 
+    @Test
+    public void testGetSetEntityStreamLambda() {
+        String address = "http://localhost:" + PORT + "/bookstore/entityecho";
+        String entity = "BOOKSTORE";
+
+        Client client = ClientBuilder.newClient();
+        client.register((ClientRequestFilter) context -> {
+            context.setEntityStream(new ReplacingOutputStream(context.getEntityStream(), 'X', 'O'));
+        });
+
+        WebTarget target = client.target(address);
+
+        Response response = target.request().post(
+                Entity.entity(entity.replace('O', 'X'), "text/plain"));
+        assertEquals(entity, response.readEntity(String.class));
+    }
+
     private static class ReplaceBodyFilter implements ClientRequestFilter {
 
         @Override