1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Fix handling of InterruptedException when locking index, bug 271909.

This commit is contained in:
Markus Schorn 2009-06-26 09:21:12 +00:00
parent dd5e2c7e1a
commit df90029032
7 changed files with 52 additions and 28 deletions

View file

@ -51,7 +51,12 @@ public class AllTypesCache {
try {
index.acquireReadLock();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return new ITypeInfo[0];
}
try {
long start = System.currentTimeMillis();
IIndexBinding[] all =
@ -80,12 +85,9 @@ public class AllTypesCache {
}
return result;
} catch(InterruptedException ie) {
ie.printStackTrace();
} finally {
index.releaseReadLock();
}
return new ITypeInfo[0];
}
/**

View file

@ -250,7 +250,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
try {
index.acquireReadLock();
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return null;
}
try {
IIndexBinding[] ibs = findBindings();
if(ibs.length>0) {
IIndexName[] names;
@ -267,8 +271,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
} catch (InterruptedException ie) {
CCorePlugin.log(ie);
} finally {
index.releaseReadLock();
}
@ -319,7 +321,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
private ITypeReference createMacroReference() {
try {
index.acquireReadLock();
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return null;
}
try {
IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
if(macros.length>0) {
for (IIndexMacro macro : macros) {
@ -331,9 +337,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
} finally {
} finally {
index.releaseReadLock();
}
return reference;
@ -374,6 +378,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
try {
index.acquireReadLock();
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return new ITypeReference[0];
}
try {
IIndexBinding[] ibs= findBindings();
HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>();
for (IIndexBinding binding : ibs) {
@ -392,9 +401,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
} catch (InterruptedException ie) {
CCorePlugin.log(ie);
CCorePlugin.log(ce);
} finally {
index.releaseReadLock();
}
@ -406,7 +413,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
try {
index.acquireReadLock();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return new ITypeReference[0];
}
try {
char[] cfn= fqn[0].toCharArray();
IIndexMacro[] ibs = index.findMacros(cfn, IndexFilter.ALL_DECLARED, new NullProgressMonitor());
// in case a file is represented multiple times in the index then we take references from
@ -424,8 +435,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
} catch (InterruptedException ie) {
CCorePlugin.log(ie);
} finally {
index.releaseReadLock();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
* Copyright (c) 2007, 2009 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.provider;
import com.ibm.icu.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -20,6 +19,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.provider.IIndexProvider;
import org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider;
@ -202,8 +203,8 @@ public final class IndexProviderManager implements IElementChangedListener {
*/
private void processCandidate(Map<String, IIndexFragment> id2fragment, IIndexFragment candidate) throws InterruptedException, CoreException {
String cid= null, csver= null, cformatID= null;
candidate.acquireReadLock();
try {
candidate.acquireReadLock();
cid= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
csver= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
cformatID= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID);
@ -218,8 +219,8 @@ public final class IndexProviderManager implements IElementChangedListener {
if(getCurrentlySupportedVersionRangeForFormat(cformatID).isIncluded(cver)) {
if(existing != null) {
String esver= null, eformatID= null;
existing.acquireReadLock();
try {
existing.acquireReadLock();
esver= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
eformatID= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID);
} finally {

View file

@ -302,8 +302,8 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
};
try {
IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
index.acquireReadLock();
try {
index.acquireReadLock();
IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
for(int i=0; i<bindings.length; i++) {
if (i % 0x1000 == 0 && monitor.isCanceled()) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -59,11 +59,15 @@ public class DefinitionFinder {
try {
index.acquireReadLock();
pdomref= index.findDefinitions(bind);
} catch (InterruptedException e) {
IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
CUIPlugin.log(status);
} finally {
return null;
}
try {
pdomref= index.findDefinitions(bind);
}
finally {
index.releaseReadLock();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -151,7 +151,13 @@ public class TranslationUnitHelper {
IIndex index;
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
index= CCorePlugin.getIndexManager().getIndex(projects);
index.acquireReadLock();
try {
index.acquireReadLock();
} catch (InterruptedException e) {
// no lock was acquired
index= null;
throw e;
}
return index;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 QNX Software Systems and others.
* Copyright (c) 2005, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -409,6 +409,8 @@ public class NewClassWizardUtil {
CUIPlugin.log(e);
return SEARCH_MATCH_ERROR;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return SEARCH_MATCH_NOTFOUND;
}
if (index == null) {
return SEARCH_MATCH_ERROR;