3131
3232import java .io .IOException ;
3333import java .nio .file .Files ;
34+ import java .nio .file .attribute .FileTime ;
35+ import java .util .ArrayList ;
36+ import java .util .Collections ;
37+ import java .util .concurrent .Executor ;
38+ import java .util .concurrent .Executors ;
39+ import java .util .concurrent .ForkJoinPool ;
3440import java .util .concurrent .Semaphore ;
3541import java .util .concurrent .atomic .AtomicBoolean ;
3642import java .util .concurrent .atomic .AtomicInteger ;
3743import java .util .function .Predicate ;
3844
45+ import org .apache .logging .log4j .core .util .ExecutorServices ;
3946import org .awaitility .Awaitility ;
4047import org .junit .jupiter .api .AfterEach ;
4148import org .junit .jupiter .api .BeforeAll ;
@@ -178,16 +185,30 @@ void indexingRescanOnOverflow() throws IOException, InterruptedException {
178185 var nModified = new AtomicInteger ();
179186 var nDeleted = new AtomicInteger ();
180187
188+ // var pool = new ForkJoinPool(1);
189+ var pool = ForkJoinPool .commonPool ();
190+ var exec = new Executor () {
191+ @ Override
192+ public void execute (Runnable command ) {
193+ System .err .println (pool .getPoolSize () + "/" + pool .getParallelism ());
194+ Thread .dumpStack ();
195+ pool .execute (command );
196+ }
197+ };
198+
181199 var watchConfig = Watcher .watch (directory , WatchScope .PATH_AND_CHILDREN )
200+ .withExecutor (exec )
182201 .approximate (OnOverflow .DIRTY )
183202 .on (e -> {
203+ System .out .println (e );
184204 var kind = e .getKind ();
185205 if (kind != OVERFLOW ) {
186206 // Threads can handle non-`OVERFLOW` events *only after*
187207 // everything is "ready" for that (in which case a token is
188208 // released to the semaphore, which is initially empty). See
189209 // below for an explanation of "readiness".
190210 semaphore .acquireUninterruptibly ();
211+ System .out .println ("Entered" );
191212 switch (e .getKind ()) {
192213 case CREATED :
193214 nCreated .incrementAndGet ();
@@ -201,7 +222,10 @@ void indexingRescanOnOverflow() throws IOException, InterruptedException {
201222 default :
202223 break ;
203224 }
225+ System .out .println ("Exiting" );
204226 semaphore .release ();
227+ } else {
228+ System .out .println ("Overflow" );
205229 }
206230 });
207231
@@ -226,7 +250,8 @@ void indexingRescanOnOverflow() throws IOException, InterruptedException {
226250
227251 var overflow = new WatchEvent (WatchEvent .Kind .OVERFLOW , directory );
228252 ((EventHandlingWatch ) watch ).handleEvent (overflow );
229- Thread .sleep (TestHelper .LONG_WAIT .toMillis ());
253+ System .out .println ("------------" );
254+ Thread .sleep (TestHelper .NORMAL_WAIT .toMillis ());
230255 // At this point, the current thread has presumably slept long
231256 // enough for the `OVERFLOW` event to have been handled by the
232257 // rescanner. This means that synthetic events must have been issued
0 commit comments