Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 68151 - Jobs state is NONE during a schedule callback
Summary: Jobs state is NONE during a schedule callback
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 64235 (view as bug list)
Depends on:
Blocks: 65992
  Show dependency tree
 
Reported: 2004-06-22 06:55 EDT by Andre Weinand CLA
Modified: 2004-10-18 16:26 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Weinand CLA 2004-06-22 06:55:59 EDT
RC3

- set DEBUG=true in NewProgressViewer
- in the debug statement in method NewProgressViewer.refresh(Object, boolean)
   add the argument "element" to the println.
- launch Eclipse from workspace
- in Job Factory enable "Reschedule"
- press "Create jobs"
Observe: after job has run for the first time, it disappears and never comes back.
On the console you don't see any remove or add events, only refresh events and a single refreshAll that 
results in the removal of the job.

I could live with the refresh (instead of add/remove) events, but the JobInfo passed as an argument is 
different between the first run and the second run of the job.
This problem probably didn't showed up in the old progress viewer because at that time lots of 
refreshAll events were generated and ensured that the viewer was always in synch with the model.
Comment 1 Andre Weinand CLA 2004-06-22 07:39:08 EDT
bug #65992 is a consequence of this.
It is probably less risky to use the workaround in #65992
than to fix this issue.
Comment 2 Andre Weinand CLA 2004-06-22 08:52:43 EDT
*** Bug 64235 has been marked as a duplicate of this bug. ***
Comment 3 Tod Creasey CLA 2004-06-22 10:41:47 EDT
The problem here is that we send the add when scheduled() is called. At this 
time the state of the job is Job.NONE so it will be filtered.

On an aboutToRun you will get the refresh rather than the add unfiltered.

I know you have a workaround for this but is Job.NONE the right state John?
Comment 4 Tod Creasey CLA 2004-06-22 10:52:17 EDT
Moving to John. We will revisit this post 3.0.
Comment 5 John Arthorne CLA 2004-06-22 12:09:06 EDT
Just so I don't forget, here is why the state is NONE during a scheduled callback:

- The state transition NONE->WAITING happens when a job is waited to the wait queue.
- This transition used to be made before broadcasting the scheduled() event.
- With a very fast job, this could mean that a job was queued, executed, and
completed *before* the scheduled event completed (especially if another job
change listener did non-trivial work).
- The result was that a job change listener would sometimes get:

ABOUT_TO_RUN
RUNNING
DONE
SCHEDULED

- This is an unexpected order of job change events. My "fix" was to broadcast
the scheduled event before adding the job to the queue. The order of job changes
events is now always reasonable and consistent, but the side-effect is that
Job.getState() returns NONE from within the scheduled() event callback.
Comment 6 John Arthorne CLA 2004-09-13 11:58:48 EDT
Andre and Tod: I am interested in making this change to ensure the state is
WAITING when in the scheduled() event. This should make your life much easier in
the progress view and other job listeners.

Since we know how sensitive this code is, my plan is to release the fix in the
first I-build after 3.1 M2. You might not need to make any code changes to
handle this, but this gives us some time to iron out any wrinkles it might cause.
Comment 7 Tod Creasey CLA 2004-09-13 12:41:53 EDT
This is fine by me.
Comment 8 John Arthorne CLA 2004-10-18 16:26:47 EDT
Fix released.  Job state will always be WAITING immediately after scheduled() is
called, including from within scheduled() job change listener callbacks. I ran
all core tests on Windows and Linux, and did some sniff testing of the UI using
the progress examples plugin on both platforms as well. I didn't expect this to
matter much, especially since no job listeners in the platform seem to listen to
the scheduled() callback at the moment anyway.