[
https://issues.apache.org/jira/browse/COMMONSSITE-184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18063390#comment-18063390
]
Gary D. Gregory commented on COMMONSSITE-184:
---------------------------------------------
[~shanjiang]
Wrong project.
> `Arg`, `Msg`, `Var`, `Field` — `clone()` copies state but `equals()` uses
> identity comparison
> ---------------------------------------------------------------------------------------------
>
> Key: COMMONSSITE-184
> URL: https://issues.apache.org/jira/browse/COMMONSSITE-184
> Project: Apache Commons All
> Issue Type: Bug
> Reporter: Shan Jiang
> Priority: Major
>
> ### Summary
> Four classes in `org.apache.commons.validator` implement `Cloneable` with
> correct `clone()`
> implementations that copy all fields, but do not override `equals()` or
> `hashCode()`.
> This means `x.clone().equals(x)` always returns `false` (identity
> comparison), violating
> the `clone()` contract:
> > "By convention, the object returned by this method should be equal to this
> > object."
> ### Affected classes
> | Class | clone() copies |
> |-------|---------------|
> | `Arg` | name, key, position, bundle, resource |
> | `Msg` | name, key, bundle, resource |
> | `Var` | name, value, jsType, bundle, resource |
> | `Field` | property, indexedProperty, indexedListProperty, key, args,
> depends, ... |
> ### How this was found
> Detected by an automated JDK conformance oracle
> (`ObjectOracles.checkCloneEqualsConsistency`).
> ---
--
This message was sent by Atlassian Jira
(v8.20.10#820010)