File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
driver-sync/src/examples/documentation Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -702,13 +702,13 @@ public void testDeletions() {
702702 }
703703
704704 @ Test
705- public void testWatch () {
705+ public void testWatch () throws InterruptedException {
706706 assumeTrue (isDiscoverableReplicaSet () && serverVersionAtLeast (3 , 6 ));
707707
708708 final MongoCollection <Document > inventory = collection ;
709709 final AtomicBoolean stop = new AtomicBoolean (false );
710710
711- new Thread (new Runnable () {
711+ Thread thread = new Thread (new Runnable () {
712712 @ Override
713713 public void run () {
714714 while (!stop .get ()) {
@@ -721,8 +721,8 @@ public void run() {
721721 collection .deleteOne (new Document ("username" , "alice" ));
722722 }
723723 }
724- }). start () ;
725-
724+ });
725+ thread . start ();
726726
727727 // Start Changestream Example 1
728728 MongoCursor <ChangeStreamDocument <Document >> cursor = inventory .watch ().iterator ();
@@ -756,6 +756,7 @@ public void run() {
756756 cursor .close ();
757757
758758 stop .set (true );
759+ thread .join ();
759760 }
760761
761762 @ Test
You can’t perform that action at this time.
0 commit comments