Skip to content

Commit

Permalink
improve removeSection method to remove sections with the same propert…
Browse files Browse the repository at this point in the history
…y key and value
  • Loading branch information
ChoiJunsik committed Feb 16, 2024
1 parent 24d836b commit 7d16ec4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions quickfixj-core/src/main/java/quickfix/SessionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<SessionID> 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);
}
}
}

0 comments on commit 7d16ec4

Please sign in to comment.