Bug 119152 - IJavaProject get and set classpath API not thread-safe
Summary: IJavaProject get and set classpath API not thread-safe
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-02 20:46 EST by Theodora Yeung CLA
Modified: 2007-06-20 04:52 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 Theodora Yeung CLA 2005-12-02 20:46:03 EST
IJavaProject.getClasspath() and IJavaProject.setClasspath() APIs not thread-safe.

Order of events in a multi-threaded environment:
Thread0 getClasspath()
Thread1 getClasspath()
Thread0 setClasspath() // add folder x to classpath
Thread1 setClasspath() // add folder y to classpath

Result: classpath entry from thread0 gets over-written by thread1.
Comment 1 Jerome Lanneluc CLA 2005-12-06 10:30:27 EST
The contract of setRawClasspath(...) is to simply set an array of classpath entries, without preserving the existing ones.
It sounds like you want to add/remove classpath entries in a thread-safe way.
Comment 2 Theodora Yeung CLA 2005-12-12 18:56:54 EST
A thread-safe add and remove would work. More importantly, everyone has to use it for it to function properly. 
Comment 3 Philipe Mulet CLA 2005-12-13 05:24:28 EST
That wouldn't be practical. Not every client wants to perform incremental add/remove to classpath.

I hate considering adding a lock to (get/set)RawClasspath given possible consequences.
Comment 4 Jerome Lanneluc CLA 2007-06-20 04:52:34 EDT
Considering that we cannot prevent client to use the existing API setRawClasspath(...) even if we deprecated it, adding a new API would not solve the issue.
No action planned.