Hi all,

I have a question about working with a 'Job' class. Why do we change a job 
status to RUNNING, FINISHED, ERROR, ABORTED outside of the class (mostly from 
schedulers)?

This approach makes impossible to synchronize 'Job' status changing with an 
actual 'Job' state (final result, finished time and so on). It may be a reason 
of some flaky tests falling. When a test code sees that the job field 
'dateFinished' is already filled with a date it tries to check a 'Job' status 
field in assert method. But a 'Job' status can still be RUNNING and test will 
fail.

Another case - when we receive a "clear" or an "append" event in 
'RemoteInterpreterEventPoller' we need to make sure that the 'Job' has not 
finished yet before starting to change its result. Otherwise we can crash the 
final result which was received from 'Interpreter.interpret()'. But if we check 
'Job.status' and see RUNNING there - this means nothing. The 'Job' can already 
be finished but with an old RUNNING status.

But if we will change a 'Job' status inside a 'Job.run()' method we can use a 
synchronize block to make sure that no other thread will split 'Job' finishing 
actions (setting a result, a finished date and a status).

Can we use this approach? Or it will cause a trouble somewhere?

Regards,
Alexander

Reply via email to