Fix FindBugs warning around locking
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / common / actor / MeteredBoundedMailboxTest.java
index 6142bf3ec55a4e2e6a884e6766960855baa0c671..d2e6b02490edffce2690e954247667f7f3a3c284 100644 (file)
@@ -53,17 +53,19 @@ public class MeteredBoundedMailboxTest {
 
         actorSystem.mailboxes().settings();
         lock.lock();
-        //queue capacity = 10
-        //need to send 12 messages; 1 message is dequeued and actor waits on lock,
-        //2nd to 11th messages are put on the queue
-        //12th message is sent to dead letter.
-        for (int i = 0; i < 12; i++) {
-            pingPongActor.tell("ping", mockReceiver.getRef());
-        }
-
-        mockReceiver.expectMsgClass(twentySeconds, DeadLetter.class);
+        try {
+            //queue capacity = 10
+            //need to send 12 messages; 1 message is dequeued and actor waits on lock,
+            //2nd to 11th messages are put on the queue
+            //12th message is sent to dead letter.
+            for (int i = 0; i < 12; i++) {
+                pingPongActor.tell("ping", mockReceiver.getRef());
+            }
 
-        lock.unlock();
+            mockReceiver.expectMsgClass(twentySeconds, DeadLetter.class);
+        } finally {
+            lock.unlock();
+        }
 
         mockReceiver.receiveN(11, twentySeconds);
     }