serializer icon indicating copy to clipboard operation
serializer copied to clipboard

Duplicate set entries with LazyHashSet.add()

Open ZockiRR opened this issue 11 months ago • 5 comments

Environment Details

  • Eclipse Serializer Version: 1.2.0
  • JDK version: 21.0.1
  • OS: Win 10
  • Used frameworks: -

Describe the bug

I am using a LazyHashSet to store a Wrapper Object, which is identified by identity. When I just use LazyHashSet.add(wrapper) it happens that the same Wrapper appears multiple times in the LazyHashSet and add returns true even tho the Wrapper is already in the set. I am currently not sure when exactly it happens, it is not always. It seems to work correctly when I do a contains check before adding.

To Reproduce

Store Objects in the LazyHashSet with no overriden equals or hashCode Method. Add the same instance multiple times. The LazyHashSet is stored with eclipse-store, but currently contains only a few objects (< 30).

Expected behavior

One Object instance only appears once in the LazyHashSet.

ZockiRR avatar Mar 17 '24 18:03 ZockiRR