From 7d16ec4d3f8487c477652b70177fc4bdc9fdef4d Mon Sep 17 00:00:00 2001 From: ChoiJunsik <2318ws@naver.com> Date: Fri, 16 Feb 2024 15:45:43 +0900 Subject: [PATCH] improve removeSection method to remove sections with the same property key and value --- .../src/main/java/quickfix/SessionSettings.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); + } } }