Skip to content

Commit 9d9bf70

Browse files
EcljpseB0Tjukzi
authored andcommitted
ContentTypeCatalog#removeContentType: add missing synchronize
For concurrent access to ContentTypeCatalog.contentTypes Found by code inspection - i wondered why internalFindContentTypesSorted() is synchronized.
1 parent 4032c40 commit 9d9bf70

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

runtime/bundles/org.eclipse.core.contenttype/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.core.contenttype; singleton:=true
5-
Bundle-Version: 3.9.500.qualifier
5+
Bundle-Version: 3.9.600.qualifier
66
Bundle-Vendor: %providerName
77
Bundle-Localization: plugin
88
Require-Bundle: org.eclipse.equinox.preferences;bundle-version="[3.2.0,4.0.0)",

runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,43 @@
1414
*******************************************************************************/
1515
package org.eclipse.core.internal.content;
1616

17-
import java.io.*;
18-
import java.util.*;
17+
import java.io.IOException;
18+
import java.io.InputStream;
19+
import java.io.Reader;
20+
import java.util.ArrayList;
21+
import java.util.Arrays;
22+
import java.util.Collection;
23+
import java.util.Collections;
24+
import java.util.Comparator;
25+
import java.util.HashMap;
26+
import java.util.HashSet;
27+
import java.util.Iterator;
28+
import java.util.List;
29+
import java.util.Map;
1930
import java.util.Map.Entry;
31+
import java.util.Set;
2032
import java.util.regex.Pattern;
21-
import org.eclipse.core.runtime.*;
22-
import org.eclipse.core.runtime.content.*;
33+
import org.eclipse.core.runtime.CoreException;
34+
import org.eclipse.core.runtime.ISafeRunnable;
35+
import org.eclipse.core.runtime.QualifiedName;
36+
import org.eclipse.core.runtime.SafeRunner;
37+
import org.eclipse.core.runtime.content.IContentDescriber;
38+
import org.eclipse.core.runtime.content.IContentDescription;
39+
import org.eclipse.core.runtime.content.IContentType;
40+
import org.eclipse.core.runtime.content.IContentTypeManager;
2341
import org.eclipse.core.runtime.content.IContentTypeManager.ISelectionPolicy;
42+
import org.eclipse.core.runtime.content.IContentTypeSettings;
43+
import org.eclipse.core.runtime.content.ITextContentDescriber;
44+
import org.eclipse.core.runtime.content.XMLRootElementContentDescriber;
45+
import org.eclipse.core.runtime.content.XMLRootElementContentDescriber2;
2446
import org.eclipse.core.runtime.preferences.IScopeContext;
2547
import org.eclipse.osgi.util.NLS;
2648

2749
public final class ContentTypeCatalog {
2850
private static final IContentType[] NO_CONTENT_TYPES = new IContentType[0];
2951

3052
/**
31-
* All fields are guarded by lock on "this"
53+
* Access to all fields is synchronized by "this"
3254
*/
3355
private final Map<ContentType, ContentType[]> allChildren = new HashMap<>();
3456
private final Map<String, IContentType> contentTypes = new HashMap<>();
@@ -725,15 +747,15 @@ private Set<ContentType> selectMatchingByName(final IScopeContext context, Colle
725747
return destination;
726748
}
727749

728-
void removeContentType(String contentTypeIdentifier) throws CoreException {
750+
synchronized void removeContentType(String contentTypeIdentifier) throws CoreException {
729751
ContentType contentType = getContentType(contentTypeIdentifier);
730752
if (contentType == null) {
731753
return;
732754
}
733755
if (!contentType.isUserDefined()) {
734756
throw new IllegalArgumentException("Content type must be user-defined."); //$NON-NLS-1$
735757
}
736-
contentTypes.remove(contentType.getId());
758+
this.contentTypes.remove(contentType.getId());
737759
}
738760

739761
}

0 commit comments

Comments
 (0)