@@ -860,7 +860,7 @@ class Output {
860
860
@ Test
861
861
public void maxUrisTestWithQueryTask () {
862
862
DataMovementManager dmManager = client .newDataMovementManager ();
863
- List <String > outputUris = new ArrayList <String >();
863
+ List <String > outputUris = Collections . synchronizedList ( new ArrayList <String >() );
864
864
865
865
DocumentMetadataHandle documentMetadata = new DocumentMetadataHandle ().withCollections ("maxUrisTest" );
866
866
WriteBatcher batcher = moveMgr .newWriteBatcher ().withDefaultMetadata (documentMetadata );
@@ -873,17 +873,13 @@ public void maxUrisTestWithQueryTask() {
873
873
batcher .flushAndWait ();
874
874
moveMgr .stopJob (batcher );
875
875
876
- class Output {
877
- int counter = 0 ;
878
- }
879
-
876
+ AtomicInteger counter = new AtomicInteger (0 );
880
877
QueryBatcher queryBatcher = dmManager .newQueryBatcher (new StructuredQueryBuilder ().collection ("maxUrisTest" ));
881
- final Output output = new Output ();
882
878
queryBatcher .setMaxBatches (2 );
883
879
queryBatcher .withBatchSize (10 )
884
880
.onUrisReady (batch -> {
885
881
outputUris .addAll (Arrays .asList (batch .getItems ()));
886
- output . counter ++ ;
882
+ counter . incrementAndGet () ;
887
883
})
888
884
.onQueryFailure ((QueryBatchException failure ) -> {
889
885
System .out .println (failure .getMessage ());
@@ -893,7 +889,7 @@ class Output {
893
889
queryBatcher .awaitCompletion ();
894
890
dmManager .stopJob (queryBatcher );
895
891
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 ));
897
893
898
894
// The number of documents should be more than maxuris but less than (maxuris+ threadcount*batchsize)
899
895
assertTrue ("Output list does not contain expected number of outputs" , (outputUris .size () >= 20 ) && outputUris .size ()<50 );
0 commit comments