Skip to content

Commit

Permalink
Merge pull request #634 from scireum/fwe/fix-user-messages
Browse files Browse the repository at this point in the history
Do not add Messages from MessageProviders to List in UserContext
  • Loading branch information
andyHa authored Jun 19, 2019
2 parents 86b55b5 + acaa191 commit c56dbd8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/sirius/web/security/UserContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class UserContext implements SubContext {
private List<Message> msgList = Lists.newArrayList();
private Map<String, String> fieldErrors = Maps.newHashMap();
private Map<String, String> fieldErrorMessages = Maps.newHashMap();
private boolean addedAdditionalMessages = false;

/**
* Retrieves the current <b>UserContext</b> from the {@link sirius.kernel.async.CallContext}.
Expand Down Expand Up @@ -326,7 +327,8 @@ public void addMessage(Message msg) {
public List<Message> getMessages() {
userMessagesCache.restoreCachedUserMessages(CallContext.getCurrent().get(WebContext.class));

if (!Sirius.isStartedAsTest()) {
if (!Sirius.isStartedAsTest() && !addedAdditionalMessages) {
addedAdditionalMessages = true;
getScope().tryAs(MaintenanceInfo.class)
.filter(info -> !info.isLocked())
.map(MaintenanceInfo::maintenanceMessage)
Expand All @@ -337,7 +339,7 @@ public List<Message> getMessages() {
messageProviders.forEach(provider -> provider.addMessages(this::addMessage));
}

return msgList;
return Collections.unmodifiableList(msgList);
}

/**
Expand Down

0 comments on commit c56dbd8

Please sign in to comment.