@@ -860,7 +860,7 @@ class Output {
860860 @ Test
861861 public void maxUrisTestWithQueryTask () {
862862 DataMovementManager dmManager = client .newDataMovementManager ();
863- List <String > outputUris = new ArrayList <String >();
863+ List <String > outputUris = Collections . synchronizedList ( new ArrayList <String >() );
864864
865865 DocumentMetadataHandle documentMetadata = new DocumentMetadataHandle ().withCollections ("maxUrisTest" );
866866 WriteBatcher batcher = moveMgr .newWriteBatcher ().withDefaultMetadata (documentMetadata );
@@ -873,17 +873,13 @@ public void maxUrisTestWithQueryTask() {
873873 batcher .flushAndWait ();
874874 moveMgr .stopJob (batcher );
875875
876- class Output {
877- int counter = 0 ;
878- }
879-
876+ AtomicInteger counter = new AtomicInteger (0 );
880877 QueryBatcher queryBatcher = dmManager .newQueryBatcher (new StructuredQueryBuilder ().collection ("maxUrisTest" ));
881- final Output output = new Output ();
882878 queryBatcher .setMaxBatches (2 );
883879 queryBatcher .withBatchSize (10 )
884880 .onUrisReady (batch -> {
885881 outputUris .addAll (Arrays .asList (batch .getItems ()));
886- output . counter ++ ;
882+ counter . incrementAndGet () ;
887883 })
888884 .onQueryFailure ((QueryBatchException failure ) -> {
889885 System .out .println (failure .getMessage ());
@@ -893,7 +889,7 @@ class Output {
893889 queryBatcher .awaitCompletion ();
894890 dmManager .stopJob (queryBatcher );
895891
896- assertTrue ("Counter value not as expected" , (output . counter >= 2 ) && (output . counter <5 ));
892+ assertTrue ("Counter value not as expected" , (counter . get () >= 2 ) && (counter . get () <5 ));
897893
898894 // The number of documents should be more than maxuris but less than (maxuris+ threadcount*batchsize)
899895 assertTrue ("Output list does not contain expected number of outputs" , (outputUris .size () >= 20 ) && outputUris .size ()<50 );
0 commit comments