Skip to content

Commit

Permalink
#625 : fix InMemoryReg..Store addr index issue on re-register and update
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Dec 4, 2018
1 parent ec0fc8b commit 4ad71b1
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ public Deregistration addRegistration(Registration registration) {
regsByAddr.put(registration.getSocketAddress(), registration);
if (registrationRemoved != null) {
Collection<Observation> observationsRemoved = unsafeRemoveAllObservations(registrationRemoved.getId());
removeFromMap(regsByAddr, registrationRemoved.getSocketAddress(), registrationRemoved);
removeFromMap(regsByRegId, registrationRemoved.getId(), registrationRemoved);
if (!registrationRemoved.getSocketAddress().equals(registration.getSocketAddress())) {
removeFromMap(regsByAddr, registrationRemoved.getSocketAddress(), registrationRemoved);
}
if (!registrationRemoved.getId().equals(registration.getId())) {
removeFromMap(regsByRegId, registrationRemoved.getId(), registrationRemoved);
}
return new Deregistration(registrationRemoved, observationsRemoved);
}
} finally {
Expand All @@ -133,7 +137,9 @@ public UpdatedRegistration updateRegistration(RegistrationUpdate update) {
// If registration is already associated to this address we don't care as we only want to keep the most
// recent binding.
regsByAddr.put(updatedRegistration.getSocketAddress(), updatedRegistration);
removeFromMap(regsByAddr, registration.getSocketAddress(), registration);
if (!registration.getSocketAddress().equals(updatedRegistration.getSocketAddress())) {
removeFromMap(regsByAddr, registration.getSocketAddress(), registration);
}

regsByRegId.put(updatedRegistration.getId(), updatedRegistration);

Expand Down

0 comments on commit 4ad71b1

Please sign in to comment.