Merge branch '6.1.x'

This commit is contained in:
rstoyanchev 2024-04-18 14:18:43 +01:00
commit aa05a6a3b3
2 changed files with 14 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -305,6 +305,9 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
return Collections.singletonList(subscriptionId);
}
else {
if (subscriptionIds.contains(subscriptionId)) {
return subscriptionIds;
}
List<String> result = new ArrayList<>(subscriptionIds.size() + 1);
result.addAll(subscriptionIds);
result.add(subscriptionId);

View File

@ -102,6 +102,16 @@ class DefaultSubscriptionRegistryTests {
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
assertThat(actual).hasSize(1);
assertThat(actual.get(sessId)).containsExactly(subId);
// Register more after destinationCache populated through findSubscriptions,
// and make sure it's still only one subscriptionId
this.registry.registerSubscription(subscribeMessage(sessId, subId, dest));
this.registry.registerSubscription(subscribeMessage(sessId, subId, dest));
actual = this.registry.findSubscriptions(createMessage(dest));
assertThat(actual).hasSize(1);
assertThat(actual.get(sessId)).containsExactly(subId);
}
@Test