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

Do not add Messages from MessageProviders to List in UserContext #634

Merged
merged 2 commits into from
Jun 19, 2019

Conversation

welzfabian
Copy link

@welzfabian welzfabian commented Jun 19, 2019

Or else the Messages of the MessageProvider and MaintenanceInfo will be added to the list everytime "public List getMessages()" is called, and therefore will be in the list multiple times if the method is called multiple times.

Messages where displayed twice, because sirius-biz calls "validate" which calls "getMessages()", when displaying a tenant, so "getMessages()" was called twice.
https://github.com/scireum/sirius-biz/blob/master/src/main/java/sirius/biz/tenants/TenantController.java#L145

Or else the Messages of the MessageProvider and MaintenanceInfo will be added to the list everytime "public List<Message> getMessages()" is called, and therefore will be in the list multiple times if the method is called multiple times.
getScope().tryAs(MessageProvider.class).ifPresent(provider -> provider.addMessages(messages::add));
getUser().tryAs(MessageProvider.class).ifPresent(provider -> provider.addMessages(messages::add));
messageProviders.forEach(provider -> provider.addMessages(messages::add));
return messages;
}

return msgList;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protect against modifications

getScope().tryAs(MessageProvider.class).ifPresent(provider -> provider.addMessages(messages::add));
getUser().tryAs(MessageProvider.class).ifPresent(provider -> provider.addMessages(messages::add));
messageProviders.forEach(provider -> provider.addMessages(messages::add));
return messages;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protect against modifications

Copy link
Member

@andyHa andyHa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

@andyHa andyHa merged commit c56dbd8 into master Jun 19, 2019
@andyHa andyHa deleted the fwe/fix-user-messages branch June 19, 2019 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants