Fix intermittent failure in testCloseCandidateRegistrationInQuickSuccession
java.lang.IllegalStateException: Optional.get() cannot be called on an absent value
at com.google.common.base.Absent.get(Absent.java:47)
at org.opendaylight.controller.cluster.datastore.entityownership.DistributedEntityOwnershipIntegrationTest.testCloseCandidateRegistrationInQuickSuccession(DistributedEntityOwnershipIntegrationTest.java:512)
Code:
if (!leaderEntityOwnershipService.getOwnershipState(ENTITY1).isPresent()
|| leaderEntityOwnershipService.getOwnershipState(ENTITY1).get() ==
EntityOwnershipState.NO_OWNER
The code inlines calls to getOwnershipState so it's possible the first call
returns a present Optional and the second call returns absent which leads to
the failure. It's safer to capture the Optional in a lcoal var.
Change-Id: I9baa120efc9924dc820435dd63217b4598731a13
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>