Bug 330358 - StructuredViewer is not thread safe
Summary: StructuredViewer is not thread safe
Status: RESOLVED INVALID
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2010-11-16 09:38 EST by Daria Huber CLA
Modified: 2011-12-12 06:59 EST (History)
2 users (show)

See Also:


Attachments
Stack trace (32.32 KB, image/jpeg)
2010-11-16 09:40 EST, Daria Huber CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daria Huber CLA 2010-11-16 09:38:16 EST
Build Identifier: 3.5.2

I have a table view which is periodically refreshed by a timer task:

UICallBack.activate("refresher");
TimerTask timerTask = new TimerTask() {
            List<Object> result = null;

            public void run() {                    
                  result = refreshInputFromDb();   
                  table.getTableViewer().getControl().getDisplay().syncExec(
                        new Runnable() {
                            public void run() {
                                updateTable(result);
                            }
                        });
                    }
                }
            }

Timer timer = new Timer();
timer.schedule(timerTask, 20000, 20000);

By doubleclicking on a table entry i stop the timer task and open an editor for editing the selected object.
public void stopRefreshTimer() {
            timerTask.cancel();
            timer.cancel();
            timer = null;
            timerTask = null;
            UICallBack.deactivate("refresher");
}

When opening the editor, a ContainerCheckedTreeViewer is initialized and filled with data. 
Sometimes is an invalid thread exception throwed. 


I think StructuredViewer is not thread safe. Is it a bug or not?

Reproducible: Always
Comment 1 Daria Huber CLA 2010-11-16 09:40:08 EST
Created attachment 183225 [details]
Stack trace
Comment 2 Ralf Sternberg CLA 2010-11-16 17:45:41 EST
Why do you think that StructuredViewer should be thread safe? All SWT widget methods must be called from the UIThread. This includes updating JFace viewers, since they manipulate the widget.

You get this error because you seem to call StructuredViewer#refresh from a non-UI thread at some point.

BTW why do you call Display#syncExec() instead of asyncExec()? I'd recommend using asyncExec unless you have a very good reason not to.
Comment 3 Daria Huber CLA 2010-11-17 02:40:37 EST
Ok, it's my mistake. I call now display#asyncExec(). But i don't call StructuredViewer#refresh from a non UI-Thread. TimerTask is the only point where i access StructuredViewer in the updateTable method.
Comment 4 Ivan Furnadjiev CLA 2010-11-19 03:15:38 EST
Is the problem fixed by using display#asyncExec()?
Comment 5 Daria Huber CLA 2010-11-23 09:29:20 EST
No this problem is still not fixed. Any idea?
Comment 6 Ivan Furnadjiev CLA 2011-04-21 04:01:11 EDT
Could you provide a complete self-running snippet that demonstrate the issue?
Comment 7 Ivan Furnadjiev CLA 2011-12-12 06:00:52 EST
Any update on the complete project/snippet to reproduce the issue?
Comment 8 Daria Huber CLA 2011-12-12 06:56:43 EST
it was a bug in my code. thank's
Comment 9 Ivan Furnadjiev CLA 2011-12-12 06:59:12 EST
(In reply to comment #8)
> it was a bug in my code. thank's
Closed as INVALID in this case.