Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip serialization of transient members. Performing serialization of inherited fields. #646

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.beans.Transient;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -182,6 +183,9 @@ private List<Access> getAccessList(Class<?> clazz) {
}
for (PropertyDescriptor desc : info.getPropertyDescriptors()) {
Method readMethod = desc.getReadMethod();
if (readMethod.isAnnotationPresent(Transient.class)) {
continue;
}
if (((CoverageType.INCLUSIVE.equals(coverageType)
&& readMethod.getAnnotation(Exclude.class) == null)
|| (CoverageType.EXCLUSIVE.equals(coverageType)
Expand Down Expand Up @@ -221,22 +225,35 @@ private List<Access> getAccessList(Class<?> clazz) {
}
break;
case FIELD:
for (Field field : clazz.getDeclaredFields()) {
if (((CoverageType.INCLUSIVE.equals(coverageType)
&& field.getAnnotation(Exclude.class) == null)
|| (CoverageType.EXCLUSIVE.equals(coverageType)
&& field.getAnnotation(Include.class) != null))
&& field.getAnnotation(Deprecated.class) == null
&& !Modifier.isTransient(field.getModifiers())) {
Access access = new FieldAccess(field);
if (access.isReadable()) {
accessList.add(access);
Class<?> cl = clazz;
while (cl != null && cl != Object.class) {
for (Field field : cl.getDeclaredFields()) {
if (Modifier.isTransient(field.getModifiers())) {
continue;
}
if (((CoverageType.INCLUSIVE.equals(coverageType)
&& field.getAnnotation(Exclude.class) == null)
|| (CoverageType.EXCLUSIVE.equals(coverageType)
&& field.getAnnotation(Include.class) != null))
&& field.getAnnotation(Deprecated.class) == null) {
Access access = new FieldAccess(field);
if (access.isReadable()) {
accessList.add(access);
}
}
}
cl = cl.getSuperclass();
}
break;
}
return accessList;
}

private AccessType getDefaultAccessType(Class<?> clazz) {
if (clazz.getPackage().getName().startsWith("org.switchyard")) {
return AccessType.BEAN;
}
return AccessType.FIELD;
}

}