Avoid duplicate subscriptionId's in destinationCache
Closes gh-32625
This commit is contained in:
parent
0e0397a385
commit
97eddb769a
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
return Collections.singletonList(subscriptionId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (subscriptionIds.contains(subscriptionId)) {
|
||||||
|
return subscriptionIds;
|
||||||
|
}
|
||||||
List<String> result = new ArrayList<>(subscriptionIds.size() + 1);
|
List<String> result = new ArrayList<>(subscriptionIds.size() + 1);
|
||||||
result.addAll(subscriptionIds);
|
result.addAll(subscriptionIds);
|
||||||
result.add(subscriptionId);
|
result.add(subscriptionId);
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,16 @@ class DefaultSubscriptionRegistryTests {
|
||||||
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
|
MultiValueMap<String, String> actual = this.registry.findSubscriptions(createMessage(dest));
|
||||||
assertThat(actual).hasSize(1);
|
assertThat(actual).hasSize(1);
|
||||||
assertThat(actual.get(sessId)).containsExactly(subId);
|
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
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue