Skip to content

Commit

Permalink
cells: Fix dumpster and default route removal
Browse files Browse the repository at this point in the history
Motivation:

Route removal for dumpster and default routes fail to work as compareAndSet
used in the code is by reference rather than equality.

Modification:

Explicitly call equals to compare the existing route with the route to be
removed.

Result:

Route removal for -dumpster and -default routes works.

Target: trunk
Require-notes: yes
Require-book: no
Request: 2.13
Request: 2.12
Request: 2.11
Request: 2.10
Acked-by: Femi Adeyemi <olufemi.segun.adeyemi@desy.de>
Patch: https://rb.dcache.org/r/8466/
(cherry picked from commit decafd2)
  • Loading branch information
gbehrmann committed Aug 12, 2015
1 parent 6b2b83e commit 6ae156c
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
Expand Down Expand Up @@ -125,12 +126,14 @@ public void delete(CellRoute route)
}
break;
case CellRoute.DEFAULT:
if (!_default.compareAndSet(route, null)) {
CellRoute currentDefault = _default.get();
if (!Objects.equals(currentDefault, route) || !_default.compareAndSet(currentDefault, null)) {
throw new IllegalArgumentException("Route entry not found for default");
}
break;
case CellRoute.DUMPSTER:
if (!_dumpster.compareAndSet(route, null)) {
CellRoute currentDumpster = _dumpster.get();
if (!Objects.equals(currentDumpster, route) || !_dumpster.compareAndSet(currentDumpster, null)) {
throw new IllegalArgumentException("Route entry not found dumpster");
}
break;
Expand Down

0 comments on commit 6ae156c

Please sign in to comment.