Avoid relying on item.hashCode() for Map and Collection properties
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
### Use case
JMeter seems to rely on `hashCode` uniqueness:
The hashcode violating code is https://github.com/apache/jmeter/blob/c7279348335b820c35ee570462cb2e0b4eb1c370/src/core/src/main/java/org/apache/jmeter/testelement/property/AbstractProperty.java#L368-L381
In other words, it generates property names based on `item.hashCode()`.
One more significant issue is that `TestCompiler` produces wrong results since `TestElement` `equals` is inconsistent with `hashCode`: https://github.com/apache/jmeter/blob/31281636281e03fc3379677b24052fe612e2e7b5/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java#L116-L132
It causes various `Map`, `Map` behave wrong. For instance, `TestCompiler` fails to property associate `SamplePackage` with the corresponding elements: https://github.com/apache/jmeter/blob/b3b2eecc396d1fc38a4c4d1cf89e3c7ade1d95d7/src/core/src/main/java/org/apache/jmeter/threads/TestCompiler.java#L72-L75
### Possible solution
_No response_
### Possible workarounds
_No response_
### JMeter Version
5.5
### Java Version
_No response_
### OS Version
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.