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 2022/12/27 22:51:41 UTC

[cxf] branch 3.6.x-fixes updated (86fb83b21a -> 399a352673)

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

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


    from 86fb83b21a Recording .gitmergeinfo Changes
     new 8ddd7177c1 CXF-8797: NameBinding ignored when implementing interface (#1045)
     new 399a352673 Recording .gitmergeinfo Changes

The 2 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 +
 .../cxf/jaxrs/model/OperationResourceInfo.java     |  4 +-
 .../cxf/jaxrs/model/OperationResourceInfoTest.java | 65 +++++++++++++++++++++-
 3 files changed, 68 insertions(+), 2 deletions(-)


[cxf] 02/02: 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.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 399a35267366297a4e2b9e7e8c53972edfa24591
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Tue Dec 27 17:23:08 2022 -0500

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

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 34c880689f..868e3af42c 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -159,6 +159,7 @@ M 8ffec0eb10eab9894ea62152e1e6f3eb962beca9
 M 905f4f91e4d0b5c4d145729f16bad90b1847f0be
 M 96a2e7f27fde6ebdffd511ce69120adfff7b9dcb
 M 96e71237bae2eb987a5fbe67d21e9e1e19f2d158
+M 9900e83b5970c32d40b797584d5cf6739952a97f
 M 9a36be5c61b1992247f7fdb416a4f0bb10f9c1d9
 M 9a8e07ab159b2492d42fddadce1e5854ceee29e8
 M 9a9d8da3eadb36ac32716988e28db544980c8e64


[cxf] 01/02: CXF-8797: NameBinding ignored when implementing interface (#1045)

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

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

commit 8ddd7177c16b5c8b1ef2ffadf1527b0e7a2090fe
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Tue Dec 27 17:16:20 2022 -0500

    CXF-8797: NameBinding ignored when implementing interface (#1045)
    
    (cherry picked from commit 9900e83b5970c32d40b797584d5cf6739952a97f)
    
    # Conflicts:
    #       rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/OperationResourceInfoTest.java
---
 .../cxf/jaxrs/model/OperationResourceInfo.java     |  4 +-
 .../cxf/jaxrs/model/OperationResourceInfoTest.java | 65 +++++++++++++++++++++-
 2 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
index 617e3cb014..38f807a194 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
@@ -81,9 +81,11 @@ public class OperationResourceInfo {
     public OperationResourceInfo(Method mInvoke, Method mAnnotated, ClassResourceInfo cri) {
         methodToInvoke = mInvoke;
         annotatedMethod = mAnnotated;
+        // Combine the name bindings from annotated method and method to invoke
+        nameBindings.addAll(AnnotationUtils.getNameBindings(mInvoke.getAnnotations()));
         if (mAnnotated != null) {
             parameters = ResourceUtils.getParameters(mAnnotated);
-            nameBindings = AnnotationUtils.getNameBindings(mAnnotated.getAnnotations());
+            nameBindings.addAll(AnnotationUtils.getNameBindings(mAnnotated.getAnnotations()));
         }
         classResourceInfo = cri;
         checkMediaTypes(null, null);
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/OperationResourceInfoTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/OperationResourceInfoTest.java
index 8835279b67..59ec4dd406 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/OperationResourceInfoTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/OperationResourceInfoTest.java
@@ -19,14 +19,22 @@
 
 package org.apache.cxf.jaxrs.model;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 
 import javax.ws.rs.Consumes;
+import javax.ws.rs.NameBinding;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -52,6 +60,30 @@ public class OperationResourceInfoTest {
         };
 
     }
+    
+    @Produces("text/xml")
+    @Consumes("application/xml")
+    interface TestInteface {
+        @Produces("text/plain")
+        void doIt();
+
+        @CustomNameBinding
+        @Consumes("application/atom+xml")
+        void doThat();
+    }
+
+    static class TestClass2 implements TestInteface {
+        @CustomNameBinding
+        @Override
+        public void doIt() {
+        }
+
+        @Override
+        public void doThat() {
+        }
+
+    }
+
 
     @Test
     public void testConsumeTypes() throws Exception {
@@ -137,6 +169,31 @@ public class OperationResourceInfoTest {
         assertEquals(0, result);
     }
 
+    @Test
+    public void testNameBindingsClass() throws NoSuchMethodException, SecurityException {
+        final Method method = TestClass2.class.getMethod("doIt", new Class[]{});
+
+        OperationResourceInfo ori = new OperationResourceInfo(
+                method,
+                AnnotationUtils.getAnnotatedMethod(TestClass2.class,  method),
+                new ClassResourceInfo(TestClass2.class));
+
+        final Set<String> names = ori.getNameBindings();
+        assertEquals(Collections.singleton(CustomNameBinding.class.getName()), names);
+    }
+
+    @Test
+    public void testNameBindingsInterface() throws NoSuchMethodException, SecurityException {
+        final Method method = TestClass2.class.getMethod("doThat", new Class[]{});
+
+        OperationResourceInfo ori = new OperationResourceInfo(
+                method,
+                AnnotationUtils.getAnnotatedMethod(TestClass2.class, method),
+                new ClassResourceInfo(TestClass2.class));
+
+        Set<String> names = ori.getNameBindings();
+        assertEquals(Collections.singleton(CustomNameBinding.class.getName()), names);
+    }
 
     private static Message createMessage() {
         Message m = new MessageImpl();
@@ -149,4 +206,10 @@ public class OperationResourceInfoTest {
         e.put(Endpoint.class, endpoint);
         return m;
     }
-}
\ No newline at end of file
+    
+    @Target({ ElementType.TYPE, ElementType.METHOD })
+    @Retention(value = RetentionPolicy.RUNTIME)
+    @NameBinding
+    public @interface CustomNameBinding {
+    }
+}