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:01:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 5115833f4 -> 3292a2c4e


[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/3292a2c4
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3292a2c4
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3292a2c4

Branch: refs/heads/3.0.x-fixes
Commit: 3292a2c4e5b2a02f296112abe9b867050460499a
Parents: 5115833
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:01:21 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/3292a2c4/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 f18530f..c3d1ba7 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;
@@ -479,20 +480,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