[
https://issues.apache.org/jira/browse/LANG-1708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18050271#comment-18050271
]
Jeremy Tonghao Sun commented on LANG-1708:
------------------------------------------
After checking the current codebase, ReflectionDiffBuilder no longer contains
a build() method that returns DiffResult, nor does it perform any equality
short-circuiting.
The responsibility for building DiffResult has been refactored into DiffBuilder,
and ReflectionDiffBuilder now only acts as a configuration wrapper.
As a result, the behavior described in this issue can no longer be reproduced
in the current implementation. This issue appears to be obsolete due to
refactoring and could likely be closed.
> Usage of "ReflectionDiffBuilder"
> --------------------------------
>
> Key: LANG-1708
> URL: https://issues.apache.org/jira/browse/LANG-1708
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.builder.*
> Affects Versions: 3.13.0
> Reporter: Gilles Sadowski
> Priority: Major
> Labels: functional, utility
> Fix For: 3.21.0
>
> Attachments: LANG-1708.unit_test.patch
>
>
> If we have either this class
> {code}
> private static class MyDirect {
> private float value;
> MyDirect(float a) {
> value = a;
> }
> }
> {code}
> or this class
> {code}
> private static class MyReference {
> private MyDirect value;
> MyReference(float a) {
> value = new MyDirect(a);
> }
> }
> {code}
> it could be argued that they are _functionally_ equivalent; IOW, code that
> uses one or the other (say, via a library) would consider it an
> implementation detail (e.g. if that library changed one for the other in some
> internal object).
> [{{ReflectionDiffBuilder}}|https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/ReflectionDiffBuilder.html]
> however behaves differently: Two instances with the same information
> contents (a primitive {{float}} value, from the caller POV) are considered
> the same in the former case and *not the same* in the latter.
> It will be noted that neither class defines an {{equals(Object)}} method;
> were it the case, the documentation of {{ReflectionDiffBuilder}}
> [constructor|https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/ReflectionDiffBuilder.html#ReflectionDiffBuilder-T-T-org.apache.commons.lang3.builder.ToStringStyle-]
> says:
> {noformat}
> If lhs == rhs or lhs.equals(rhs) then the builder will not evaluate any calls
> to append(...) and will return an empty DiffResult when build() is executed.
> {noformat}
> However there are the use-cases
> # (as above) where {{equals}} was not overridden (and the source code cannot
> be modified by the user who wants to list the differences, or ensure there
> are none, functionally), and
> # where one would want to list (potential) differences that could exist even
> if {{equals}} would return {{true}} (e.g. if {{equals}} is buggy).
> IMHO:
> * Current behaviour is inconsistent (even if intended).
> * There should be a way to disable the equality check (i.e. *always* use
> reflection to list the differences).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)