Closed andi-huber closed 4 years ago
supposed fix: PR 284 https://github.com/unitsofmeasurement/indriya/pull/284/files
ProductUnit#hashCode()
had a side-effect, such that when called it would sort its unit dimension elements. Which is semantically incorrect. According to spec the initial order must be preserved.
Also this sorting had the potential of interfering with other threads, that would access these unit dimension elements concurrently.
We fix both here by using a defensive copy of the elements before sorting, while preserving the initial order of the unit dimension elements. As an optimization bonus, we do cash the calculated hashCode, so the unit element sorting is only required once per instance.
merged
same as with https://github.com/unitsofmeasurement/uom-se/issues/210