in core/src/main/java/org/apache/struts2/ognl/OgnlUtil.java [525:588]
public void copy(final Object from,
final Object to,
final Map<String, Object> context,
Collection<String> exclusions,
Collection<String> inclusions,
Class<?> editable) {
if (from == null || to == null) {
LOG.warn(
"Skipping attempt to copy from, or to, a null source.", new RuntimeException());
return;
}
final Map<String, Object> contextFrom = createDefaultContext(from);
final Map<String, Object> contextTo = createDefaultContext(to);
PropertyDescriptor[] fromPds;
PropertyDescriptor[] toPds;
try {
fromPds = getPropertyDescriptors(from);
if (editable != null) {
toPds = getPropertyDescriptors(editable);
} else {
toPds = getPropertyDescriptors(to);
}
} catch (IntrospectionException e) {
LOG.error("An error occurred", e);
return;
}
Map<String, PropertyDescriptor> toPdHash = new HashMap<>();
for (PropertyDescriptor toPd : toPds) {
toPdHash.put(toPd.getName(), toPd);
}
for (PropertyDescriptor fromPd : fromPds) {
if (fromPd.getReadMethod() == null) {
continue;
}
if (exclusions != null && exclusions.contains(fromPd.getName()) ||
inclusions != null && !inclusions.contains(fromPd.getName())) {
continue;
}
PropertyDescriptor toPd = toPdHash.get(fromPd.getName());
if (toPd == null || toPd.getWriteMethod() == null) {
continue;
}
try {
Object value = ognlGet(fromPd.getName(),
contextFrom,
from,
null,
context,
this::checkEnableEvalExpression);
ognlSet(fromPd.getName(), contextTo, to, value, context);
} catch (OgnlException e) {
LOG.debug("Got OGNL exception", e);
}
}
}