Skip to content

Commit

Permalink
Bug 567171 - fix synchronization issue in DeltaProcessingState
Browse files Browse the repository at this point in the history
Fix problem introduced in Bug 431275. Synchronized on a field always
uses the object. It does not make sense if you assign a new object to
the field.

Change-Id: I7835bc1c92b9962c3aa811d6b6e5db4c578d91d6
Signed-off-by: Carsten Hammer <[email protected]>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/168851
Tested-by: JDT Bot <[email protected]>
Reviewed-by: Jörg Kubitz <[email protected]>
Reviewed-by: Andrey Loskutov <[email protected]>
  • Loading branch information
carstenartur authored and iloveeclipse committed Apr 21, 2021
1 parent d01976d commit 1e8d2c3
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public void doNotUse() {
* This is null if no refresh is needed.
*/
private Set<IJavaElement> externalElementsToRefresh;
private final Object mutex = new Object();

/*
* Need to clone defensively the listener information, in case some listener is reacting to some notification iteration by adding/changing/removing
Expand Down Expand Up @@ -187,7 +188,7 @@ public DeltaProcessor getDeltaProcessor() {
}

public ClasspathChange addClasspathChange(IProject project, IClasspathEntry[] oldRawClasspath, IPath oldOutputLocation, IClasspathEntry[] oldResolvedClasspath) {
synchronized (this.classpathChanges) {
synchronized (this.mutex) {
ClasspathChange change = this.classpathChanges.get(project);
if (change == null) {
change = new ClasspathChange((JavaProject) JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(project), oldRawClasspath, oldOutputLocation, oldResolvedClasspath);
Expand All @@ -205,13 +206,13 @@ public ClasspathChange addClasspathChange(IProject project, IClasspathEntry[] ol
}

public ClasspathChange getClasspathChange(IProject project) {
synchronized (this.classpathChanges) {
synchronized (this.mutex) {
return this.classpathChanges.get(project);
}
}

public Map<IProject, ClasspathChange> removeAllClasspathChanges() {
synchronized (this.classpathChanges) {
synchronized (this.mutex) {
Map<IProject, ClasspathChange> result = this.classpathChanges;
this.classpathChanges = new LinkedHashMap<>(result.size());
return result;
Expand Down

0 comments on commit 1e8d2c3

Please sign in to comment.