[
https://issues.apache.org/jira/browse/LANG-1708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18050272#comment-18050272
]
Jeremy Tonghao Sun commented on LANG-1708:
------------------------------------------
This issue appears to be based on an earlier implementation.
In the current codebase, ReflectionDiffBuilder no longer performs the diff
operation itself, nor does it contain a build() method returning DiffResult
or any equality short-circuiting logic.
The responsibility for building DiffResult has been refactored into DiffBuilder,
and the behavior described here can no longer be reproduced on current master.
Given that the original conditions no longer exist, this no longer represents
an active bug, but rather an issue that has become obsolete due to refactoring.
> 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)