Skip to content

Commit fd1926f

Browse files
authored
Merge pull request #766 from ChoiJunsik/improve-remove-section-function
update removeSection method to remove sections with the same property key and value
2 parents 663fb55 + 7d16ec4 commit fd1926f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

quickfixj-core/src/main/java/quickfix/SessionSettings.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,12 +887,13 @@ public void removeSection(final SessionID sessionID) throws ConfigError {
887887
}
888888

889889
public void removeSection(final String propertyKey, final String propertyValue) throws ConfigError {
890-
SessionID sessionIdToRemove = sections.entrySet().stream()
890+
List<SessionID> sessionIDs = sections.entrySet().stream()
891891
.filter(entry -> propertyValue.equals(entry.getValue().get(propertyKey)))
892892
.map(Map.Entry::getKey)
893-
.findFirst()
894-
.orElseThrow(() -> new ConfigError("Session not found"));
893+
.collect(Collectors.toList());
895894

896-
sections.remove(sessionIdToRemove);
895+
for (SessionID sessionID : sessionIDs) {
896+
this.removeSection(sessionID);
897+
}
897898
}
898899
}

0 commit comments

Comments
 (0)