Skip to content

Commit aa05a6a

Browse files
committed
Merge branch '6.1.x'
2 parents a985c0b + 97eddb7 commit aa05a6a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -305,6 +305,9 @@ private void addMatchedSubscriptionId(
305305
return Collections.singletonList(subscriptionId);
306306
}
307307
else {
308+
if (subscriptionIds.contains(subscriptionId)) {
309+
return subscriptionIds;
310+
}
308311
List<String> result = new ArrayList<>(subscriptionIds.size() + 1);
309312
result.addAll(subscriptionIds);
310313
result.add(subscriptionId);

spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ void registerSameSubscriptionTwice() {
102102
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
103103
assertThat(actual).hasSize(1);
104104
assertThat(actual.get(sessId)).containsExactly(subId);
105+
106+
// Register more after destinationCache populated through findSubscriptions,
107+
// and make sure it's still only one subscriptionId
108+
109+
this.registry.registerSubscription(subscribeMessage(sessId, subId, dest));
110+
this.registry.registerSubscription(subscribeMessage(sessId, subId, dest));
111+
112+
actual = this.registry.findSubscriptions(createMessage(dest));
113+
assertThat(actual).hasSize(1);
114+
assertThat(actual.get(sessId)).containsExactly(subId);
105115
}
106116

107117
@Test

0 commit comments

Comments
 (0)