ivanshuba commented on PR #227:
URL: https://github.com/apache/commons-geometry/pull/227#issuecomment-1898973285
@aherbert
`GreatCircle` class was using the `Objects.hash()` wrapper method to
calculate hash value. In its turn, it was calling the `Arrays.hashCode()`
method.
Unfortunately, somewhere during the process, this fails to prevent hash
collisions when it's calculated for the `GreatCircle` instances. I haven't
investigated the cause yet. As a guess, this might be related to that the
`Precision.DoubleEquivalence`'s `hashCode()` method is not overridden, not sure.
Anyways, the usage of the same approach as in `Vector2D` and `Vector3D`
classes resolves the issue for the `GreatCircle` also.
```java
@Override
public int hashCode() {
int result = 1;
long temp;
temp = pole.hashCode();
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = u.hashCode();
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = v.hashCode();
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = getPrecision().hashCode();
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
```
Additionally, I fixed my incorrect indentations and variable naming added
previously to prevent check errors.
_All_ tests are passing now when I run them through Maven.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]