Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseCloudEvent.getExtensionNames() breaks cloud event encapsulation #581

Open
mskuba01 opened this issue Jun 30, 2023 · 2 comments
Open
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mskuba01
Copy link

please replace

@Override
public Set<String> getExtensionNames() {
    return this.extensions.keySet();
}

with something, like

@Override
public Set<String> getExtensionNames() {
    return Collections.unmodifiableSet (this.extensions.keySet());
}

to avoid breaking encapsulation.

More details can be found here

https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html#keySet--
Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.

@pierDipi pierDipi added enhancement New feature or request help wanted Extra attention is needed labels Jul 3, 2023
@pierDipi
Copy link
Member

pierDipi commented Jul 3, 2023

Hi @mskuba01, thanks for the suggestion, feel free to propose a PR

@thedevhaider
Copy link

@mskuba01, Yeah this makes sense. The first snippet returns a modifiable keySet which breaks the encapsulation. @pierDipi can you please assign this to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants