diff --git a/quickfixj-core/src/main/java/quickfix/SessionSettings.java b/quickfixj-core/src/main/java/quickfix/SessionSettings.java index de52063503..5a0274cd85 100644 --- a/quickfixj-core/src/main/java/quickfix/SessionSettings.java +++ b/quickfixj-core/src/main/java/quickfix/SessionSettings.java @@ -887,12 +887,13 @@ public void removeSection(final SessionID sessionID) throws ConfigError { } public void removeSection(final String propertyKey, final String propertyValue) throws ConfigError { - SessionID sessionIdToRemove = sections.entrySet().stream() + List sessionIDs = sections.entrySet().stream() .filter(entry -> propertyValue.equals(entry.getValue().get(propertyKey))) .map(Map.Entry::getKey) - .findFirst() - .orElseThrow(() -> new ConfigError("Session not found")); + .collect(Collectors.toList()); - sections.remove(sessionIdToRemove); + for (SessionID sessionID : sessionIDs) { + this.removeSection(sessionID); + } } }