Skip to content

Performance: Account class didn't implement equals() and hashCode() => wrong results in getAccounts().join().contains() #679

@gterminator

Description

@gterminator

Hi,
the class Account didnt implement the equals() and hashCode() methods. Therefore the Set cannot determine that an object is in or not.

Problem
boolean isAccountInCache = app.getAccounts().join().contains(myAccount);
This is not working because of the missing methods. As a Workaround, we have to iterate trough every element in this cache. Which make this library very inefficient and latency expensive.

Problematic Workaround
boolean isAccountInCache = app.getAccounts().join().stream().anymatch( acc -> acc.username().equals(myusername));
This is working well for ~100 accounts in the cache, but in larger applications with more than 10-100k users in cache this will be a problem. Imagine we iterate for every request 10k times through this accounts set.

Maybe I find time to open a PR and/or provide a PoC of this problem.

Best regards

Max

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementA request or suggestion to improve some aspect of the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions