How to avoid out of order of processTerminated and consumeTestResultsAvailable in plugin ideabuck



  In Intellij plugin ideabuck, at the end of build and test, we will have 2 things, one is "buck.test.event" event handling, the other is processTerminated handling, in rare case, the later may run faster than the former, then we will get "Test framework quit unexpectedly".

  How to avoid this, any suggestions?

  Here is the calling trace of the 2 handling.

  Best regard:



1. "buck.test.available" handling

consumeTestResultsAvailable:160, BuckToGeneralTestEventsConverter

invoke0:-1, NativeMethodAccessorImpl

invoke:62, NativeMethodAccessorImpl

invoke:43, DelegatingMethodAccessorImpl

invoke:498, Method

deliverMessage:114, MessageBusConnectionImpl

doPumpMessages:393, MessageBusImpl

pumpWaitingBuses:354, MessageBusImpl

pumpMessages:343, MessageBusImpl

pumpMessages:327, MessageBusImpl

sendMessage:320, MessageBusImpl

access$100:29, MessageBusImpl

invoke:192, MessageBusImpl$1

consumeTestResultsAvailable:-1, $Proxy211

handleEvent:40, BuckResultsAvailableHandler

lambda$handleEvent$0:58, BuckEventsQueue

run:-1, 1059739759

call:511, Executors$RunnableAdapter

run:266, FutureTask

runWorker:1149, ThreadPoolExecutor

run:624, ThreadPoolExecutor$Worker

run:748, Thread




2. processTerminated

processTerminated:101, BuckToGeneralTestEventsConverter$1

invoke:-1, GeneratedMethodAccessor677

invoke:43, DelegatingMethodAccessorImpl

invoke:498, Method

invoke:214, ProcessHandler$2

  listene BuckToGeneralTestEventsConverter @43897

processTerminated:-1, $Proxy23

lambda$notifyTerminated$2:172, ProcessHandler

run:-1, 562303110

execute:247, ProcessHandler$TasksRunner

notifyTerminated:155, ProcessHandler

notifyProcessTerminated:151, ProcessHandler

onOSProcessTerminated:61, BaseProcessHandler

onOSProcessTerminated:112, OSProcessHandler

lambda$startNotified$0:99, BaseOSProcessHandler$1

consume:-1, 1669027731

lambda$null$0:61, ProcessWaitFor

run:-1, 2081548076

runUnderThreadName:224, ConcurrencyUtil

lambda$new$1:43, ProcessWaitFor

run:-1, 1501238234

call:511, Executors$RunnableAdapter

run:266, FutureTask

runWorker:1149, ThreadPoolExecutor

run:624, ThreadPoolExecutor$Worker

run:748, Thread





in which order do you receive events? how do you handle events in your converter?




Anna Kozlova  Usually, BuckToGeneralTestEventsConverter handles "buck.test.available" first in one thread, and it handles processTerminated later in another thread.

In rare case, the later takes place first, when it handles processTerminated, it will dispose the connection (and/or processor associate with the connection), through which it subscribes to topic "buck.test.available", so when it handles the "buck.test.available" event, it can NOT run through, as the result, the root suites doesn't have child(our test)


Why can't you use the same thread for later invocation of `processTerminated`? BTW All events are fired in "output reader" thread and can be processed synchronously 


What I see is they are handled by 2 different threads:

Process termination is handled by thread "Thread[buckw,4,Idea Thread Group]"
Events are handled by thread "Thread[pool-4-thread-1,5,Idea Thread Group]"


Yes, all test events are come in one thread, processTerminated in another. This way `` may be called twice from 2 different threads. But it looks like you don't send `finishTesting` event and one from processTerminated is used.

From the issue: "Test framework quit unexpectedly" is received when test framework didn't attach itself to the process. When do you send this event actually?