diff --git a/ext/proxy-client/src/main/java/org/glassfish/jersey/client/proxy/RequestParameters.java b/ext/proxy-client/src/main/java/org/glassfish/jersey/client/proxy/RequestParameters.java index cd9d92a8f0..aeffb03dc8 100644 --- a/ext/proxy-client/src/main/java/org/glassfish/jersey/client/proxy/RequestParameters.java +++ b/ext/proxy-client/src/main/java/org/glassfish/jersey/client/proxy/RequestParameters.java @@ -35,6 +35,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -43,6 +44,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * Collector to retrieve parameters for setting up the HTTP request sent in the invoke method of WebResourceFactory @@ -145,7 +147,7 @@ private void addBeanParameter(final Object beanParam) throws IllegalAccessException, IntrospectionException, InvocationTargetException { Class beanClass = beanParam.getClass(); List fields = new ArrayList<>(); - getAllFields(fields, beanClass); + getAllNonStaticFields(fields, beanClass); for (final Field field : fields) { Object value = null; @@ -178,11 +180,15 @@ private void addBeanParameter(final Object beanParam) } } - private List getAllFields(List fields, Class type) { - fields.addAll(Arrays.asList(type.getDeclaredFields())); + private List getAllNonStaticFields(List fields, Class type) { + + List nonStaticFields = Arrays.stream(type.getDeclaredFields()) + .filter(field -> !Modifier.isStatic(field.getModifiers())) + .collect(Collectors.toList()); + fields.addAll(nonStaticFields); if (type.getSuperclass() != null) { - getAllFields(fields, type.getSuperclass()); + getAllNonStaticFields(fields, type.getSuperclass()); } return fields; diff --git a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/MyBeanParamWithPrivateField.java b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/MyBeanParamWithPrivateField.java index beb98f6461..06250c7262 100644 --- a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/MyBeanParamWithPrivateField.java +++ b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/MyBeanParamWithPrivateField.java @@ -27,6 +27,10 @@ public class MyBeanParamWithPrivateField { @QueryParam("privateFieldParam") private String privateFieldParam; + private static String privateStaticField; + + static String staticField; + public MyBeanParamWithPrivateField() {} public String getPrivateFieldParam() { @@ -36,4 +40,20 @@ public String getPrivateFieldParam() { public void setPrivateFieldParam(String privateFieldParam) { this.privateFieldParam = privateFieldParam; } + + public static String getPrivateStaticField() { + return privateStaticField; + } + + public static void setPrivateStaticField(String privateStaticField) { + MyBeanParamWithPrivateField.privateStaticField = privateStaticField; + } + + public static String getStaticField() { + return staticField; + } + + public static void setStaticField(String staticField) { + MyBeanParamWithPrivateField.staticField = staticField; + } }