This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/struts.git
commit c85ec6dfafeb7a898f1098b0e561aa445787f12b Author: Lukasz Lenart <[email protected]> AuthorDate: Fri Oct 23 08:26:06 2026 +0200 WW-5790 refactor(rest): read the baseline value only when a comparison needs it Co-Authored-By: Claude Mythos 5.1 <[email protected]> --- .../java/org/apache/struts2/rest/ContentTypeInterceptor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/ContentTypeInterceptor.java b/plugins/rest/src/main/java/org/apache/struts2/rest/ContentTypeInterceptor.java index a0afa0b61..d98b22544 100644 --- a/plugins/rest/src/main/java/org/apache/struts2/rest/ContentTypeInterceptor.java +++ b/plugins/rest/src/main/java/org/apache/struts2/rest/ContentTypeInterceptor.java @@ -241,15 +241,15 @@ public class ContentTypeInterceptor extends AbstractInterceptor { } Object sourceValue = readMethod.invoke(source); - Object baselineValue = baseline == null ? null : readMethod.invoke(baseline); - // A null, or a leaf or collection equal to the baseline's constructor default, reads as "not in - // the body": copying it would overwrite what params or prepare() put on the target. The cost is - // that an explicit null, a primitive at its zero value, an empty collection, or any body value - // equal to the constructor default is not applied either. A nested bean is compared leaf by leaf - // below, never through its own equals. + // A null, or a non-nested value (leaf, collection, map, array) equal to the baseline's constructor + // default, reads as "not in the body": copying it would overwrite what params or prepare() put on + // the target. The cost is that an explicit null, a primitive at its zero value, an empty collection, + // or any body value equal to the constructor default is not applied either. A nested bean is + // compared leaf by leaf below, never through its own equals. if (sourceValue == null) { continue; } + Object baselineValue = baseline == null ? null : readMethod.invoke(baseline); boolean nestedBean = isNestedBeanType(sourceValue.getClass()); if (!nestedBean && baseline != null && Objects.deepEquals(sourceValue, baselineValue)) { continue;
