BUG-5247: Fix Optional.get() on absent return 24/34524/2
authorRobert Varga <rovarga@cisco.com>
Thu, 11 Feb 2016 23:41:25 +0000 (00:41 +0100)
committerRobert Varga <rovarga@cisco.com>
Thu, 11 Feb 2016 23:48:40 +0000 (00:48 +0100)
The following exception is seen:

testCloseCandidateRegistrationInQuickSuccession(org.opendaylight.controller.cluster.datastore.entityownership.DistributedEntityOwnershipIntegrationTest)  Time elapsed: 3.158 sec  <<< ERROR!
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:404)

Change-Id: I3765a05a332f4abba550177ae5516eb2644ea94d
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java

index f69567c..0b49357 100644 (file)
@@ -402,7 +402,9 @@ public class DistributedEntityOwnershipIntegrationTest {
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
             if(!leaderEntityOwnershipService.getOwnershipState(ENTITY1).isPresent() ||
                     !leaderEntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
+                    follower1EntityOwnershipService.getOwnershipState(ENTITY1).isPresent() &&
                     !follower1EntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
+                    follower2EntityOwnershipService.getOwnershipState(ENTITY1).isPresent() &&
                     !follower2EntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
                     leaderChangeCaptor.getAllValues().size() > 0 && !leaderChangeCaptor.getValue().hasOwner() &&
                     leaderChangeCaptor.getAllValues().size() > 0 && !follower1ChangeCaptor.getValue().hasOwner() &&