[ 
https://issues.apache.org/jira/browse/VALIDATOR-509?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory updated VALIDATOR-509:
--------------------------------------
    Priority: Minor  (was: Major)

> apache/commons-validator — Cloneable classes missing equals()/hashCode()
> ------------------------------------------------------------------------
>
>                 Key: VALIDATOR-509
>                 URL: https://issues.apache.org/jira/browse/VALIDATOR-509
>             Project: Commons Validator
>          Issue Type: Bug
>            Reporter: Shan Jiang
>            Priority: Minor
>
> `Arg`, `Msg`, `Var`, `Field` — `clone()` copies state but `equals()` uses 
> identity comparison
> ### 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)

Reply via email to