cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6367] Updating JAX-RS proxy code to do a limited check of BeanParam bean fields
Date Thu, 23 Apr 2015 13:00:47 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 78a46c1b0 -> 9ca3275b8


[CXF-6367] Updating JAX-RS proxy code to do a limited check of BeanParam bean fields


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9ca3275b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9ca3275b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9ca3275b

Branch: refs/heads/master
Commit: 9ca3275b8753cb1beccf1530415c9a061f110675
Parents: 78a46c1
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Apr 23 14:00:28 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Apr 23 14:00:28 2015 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/client/ClientProxyImpl.java       | 28 +++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9ca3275b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
index bb70bad..f4ea6de 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxrs.client;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
@@ -476,20 +477,33 @@ public class ClientProxyImpl extends AbstractClient implements
         
         for (Method m : bean.getClass().getMethods()) {
             if (m.getName().startsWith("set")) {
-                Annotation annotation = m.getAnnotation(annClass);
-                if (annotation != null) {
-                    try {
-                        String propertyName = m.getName().substring(3);
+                try {
+                    String propertyName = m.getName().substring(3);
+                    Annotation annotation = m.getAnnotation(annClass);
+                    if (annotation != null) {
                         Method getter = bean.getClass().getMethod("get" + propertyName, new
Class[]{});
                         Object value = getter.invoke(bean, new Object[]{});
                         if (value != null) {
                             String annotationValue = AnnotationUtils.getAnnotationValue(annotation);
                             values.put(annotationValue, new BeanPair(value, m.getParameterAnnotations()[0]));
                         }
-                    } catch (Throwable t) {
-                        // ignore
+                    } else {
+                        Field f = bean.getClass().getField(propertyName);
+                        if (f == null) {
+                            continue;
+                        }
+                        annotation = f.getAnnotation(annClass);
+                        if (annotation != null) {
+                            Object value = f.get(bean);
+                            if (value != null) {
+                                String annotationValue = AnnotationUtils.getAnnotationValue(annotation);
+                                values.put(annotationValue, new BeanPair(value, f.getAnnotations()));
+                            }    
+                        }
                     }
-                }
+                } catch (Throwable t) {
+                    // ignore
+                }    
             }
         }
         return values;


Mime
View raw message