Skip to content

Commit 87ba1a0

Browse files
tcheericclaude
andcommitted
fix: address Codex PR review comments
- Restrict tag-filter matching to first parameter (value position) per NIP-01 - Defensively copy builder lists in EventFilter constructor to prevent shared mutable state when reusing builders - Remove duplicate notifyClose() call from close() since afterConnectionClosed already handles listener notification Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6e8a1bf commit 87ba1a0

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

nostr-java-client/src/main/java/nostr/client/springwebsocket/NostrRelayClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,6 @@ public void close() throws IOException {
475475
}
476476
if (open) {
477477
clientSession.close();
478-
connectionState.set(ConnectionState.CLOSED);
479-
notifyClose();
480478
}
481479
}
482480
}

nostr-java-event/src/main/java/nostr/event/filter/EventFilter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public class EventFilter {
4040
private final Map<String, List<String>> tagFilters;
4141

4242
private EventFilter(Builder builder) {
43-
this.ids = Collections.unmodifiableList(builder.ids);
44-
this.authors = Collections.unmodifiableList(builder.authors);
45-
this.kinds = Collections.unmodifiableList(builder.kinds);
43+
this.ids = Collections.unmodifiableList(new ArrayList<>(builder.ids));
44+
this.authors = Collections.unmodifiableList(new ArrayList<>(builder.authors));
45+
this.kinds = Collections.unmodifiableList(new ArrayList<>(builder.kinds));
4646
this.since = builder.since;
4747
this.until = builder.until;
4848
this.limit = builder.limit;
@@ -80,7 +80,7 @@ public Predicate<GenericEvent> toPredicate() {
8080
.filter(GenericTag.class::isInstance)
8181
.map(GenericTag.class::cast)
8282
.filter(t -> t.getCode().equals(tagCode))
83-
.anyMatch(t -> t.getParams().stream().anyMatch(values::contains)));
83+
.anyMatch(t -> !t.getParams().isEmpty() && values.contains(t.getParams().get(0))));
8484
}
8585
}
8686

0 commit comments

Comments
 (0)