mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 209770: CConfigBasedDescriptor.get not thread-safe
This commit is contained in:
parent
ad075de767
commit
5a608fee1c
1 changed files with 50 additions and 45 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Intel Corporation and others.
|
* Copyright (c) 2007, 2008 Intel Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - Initial API and implementation
|
* Intel Corporation - Initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core;
|
package org.eclipse.cdt.internal.core;
|
||||||
|
|
||||||
|
@ -48,14 +49,14 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
private ICConfigurationDescription fCfgDes;
|
private ICConfigurationDescription fCfgDes;
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
private COwner fOwner;
|
private COwner fOwner;
|
||||||
private HashMap fDesMap = new HashMap();
|
private final HashMap fDesMap = new HashMap();
|
||||||
private HashMap fStorageDataElMap = new HashMap();
|
private final HashMap fStorageDataElMap = new HashMap();
|
||||||
private boolean fApplyOnChange = true;
|
private boolean fApplyOnChange = true;
|
||||||
private boolean fIsDirty;
|
private boolean fIsDirty;
|
||||||
private CDescriptorEvent fOpEvent;
|
private CDescriptorEvent fOpEvent;
|
||||||
private boolean fIsOpStarted;
|
private boolean fIsOpStarted;
|
||||||
|
|
||||||
class CConfigBaseDescriptorExtensionReference implements ICExtensionReference{
|
final class CConfigBaseDescriptorExtensionReference implements ICExtensionReference{
|
||||||
private ICConfigExtensionReference fCfgExtRef;
|
private ICConfigExtensionReference fCfgExtRef;
|
||||||
CConfigBaseDescriptorExtensionReference(ICConfigExtensionReference cfgRef){
|
CConfigBaseDescriptorExtensionReference(ICConfigExtensionReference cfgRef){
|
||||||
fCfgExtRef = cfgRef;
|
fCfgExtRef = cfgRef;
|
||||||
|
@ -191,6 +192,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
|
|
||||||
private CConfigBaseDescriptorExtensionReference create(ICConfigExtensionReference ref){
|
private CConfigBaseDescriptorExtensionReference create(ICConfigExtensionReference ref){
|
||||||
CConfigBaseDescriptorExtensionReference dr = new CConfigBaseDescriptorExtensionReference(ref);
|
CConfigBaseDescriptorExtensionReference dr = new CConfigBaseDescriptorExtensionReference(ref);
|
||||||
|
synchronized (fDesMap) {
|
||||||
ArrayList list = (ArrayList)fDesMap.get(ref.getExtensionPoint());
|
ArrayList list = (ArrayList)fDesMap.get(ref.getExtensionPoint());
|
||||||
if(list == null){
|
if(list == null){
|
||||||
list = new ArrayList(1);
|
list = new ArrayList(1);
|
||||||
|
@ -199,6 +201,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
list.ensureCapacity(list.size() + 1);
|
list.ensureCapacity(list.size() + 1);
|
||||||
}
|
}
|
||||||
list.add(dr);
|
list.add(dr);
|
||||||
|
}
|
||||||
return dr;
|
return dr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,16 +231,17 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
ICExtensionReference[] extRefs = new ICExtensionReference[cfgRefs.length];
|
ICExtensionReference[] extRefs = new ICExtensionReference[cfgRefs.length];
|
||||||
|
synchronized (fDesMap) {
|
||||||
ArrayList list = (ArrayList)fDesMap.get(extensionPoint);
|
ArrayList list = (ArrayList)fDesMap.get(extensionPoint);
|
||||||
// if(list == null){
|
// if(list == null){
|
||||||
// list = new ArrayList(cfgRefs.length);
|
// list = new ArrayList(cfgRefs.length);
|
||||||
// fDesMap.put(extensionPoint, list);
|
// fDesMap.put(extensionPoint, list);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// list = (ArrayList)list.clone();
|
// list = (ArrayList)list.clone();
|
||||||
//
|
//
|
||||||
// CConfigBaseDescriptorExtensionReference[] refs = (CConfigBaseDescriptorExtensionReference[])list.
|
// CConfigBaseDescriptorExtensionReference[] refs = (CConfigBaseDescriptorExtensionReference[])list.
|
||||||
// toArray(new CConfigBaseDescriptorExtensionReference[list.size()]);
|
// toArray(new CConfigBaseDescriptorExtensionReference[list.size()]);
|
||||||
int num = cfgRefs.length - 1;
|
int num = cfgRefs.length - 1;
|
||||||
|
|
||||||
for(int i = cfgRefs.length - 1; i >= 0; i--){
|
for(int i = cfgRefs.length - 1; i >= 0; i--){
|
||||||
|
@ -267,6 +271,7 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
|
|
||||||
list.addAll(Arrays.asList(extRefs));
|
list.addAll(Arrays.asList(extRefs));
|
||||||
list.trimToSize();
|
list.trimToSize();
|
||||||
|
}
|
||||||
return extRefs;
|
return extRefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue