mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Fix handling of InterruptedException when locking index, bug 271909.
This commit is contained in:
parent
dd5e2c7e1a
commit
df90029032
7 changed files with 52 additions and 28 deletions
|
@ -51,7 +51,12 @@ public class AllTypesCache {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return new ITypeInfo[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
IIndexBinding[] all =
|
IIndexBinding[] all =
|
||||||
|
@ -80,12 +85,9 @@ public class AllTypesCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch(InterruptedException ie) {
|
|
||||||
ie.printStackTrace();
|
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
return new ITypeInfo[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -250,7 +250,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
IIndexBinding[] ibs = findBindings();
|
IIndexBinding[] ibs = findBindings();
|
||||||
if(ibs.length>0) {
|
if(ibs.length>0) {
|
||||||
IIndexName[] names;
|
IIndexName[] names;
|
||||||
|
@ -267,8 +271,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||||
}
|
}
|
||||||
} catch(CoreException ce) {
|
} catch(CoreException ce) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(ce);
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
CCorePlugin.log(ie);
|
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
@ -319,7 +321,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||||
private ITypeReference createMacroReference() {
|
private ITypeReference createMacroReference() {
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
|
IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
|
||||||
if(macros.length>0) {
|
if(macros.length>0) {
|
||||||
for (IIndexMacro macro : macros) {
|
for (IIndexMacro macro : macros) {
|
||||||
|
@ -331,9 +337,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||||
}
|
}
|
||||||
} catch(CoreException ce) {
|
} catch(CoreException ce) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(ce);
|
||||||
} catch (InterruptedException ie) {
|
} finally {
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
} finally {
|
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
return reference;
|
return reference;
|
||||||
|
@ -374,6 +378,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||||
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
|
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return new ITypeReference[0];
|
||||||
|
}
|
||||||
|
try {
|
||||||
IIndexBinding[] ibs= findBindings();
|
IIndexBinding[] ibs= findBindings();
|
||||||
HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>();
|
HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>();
|
||||||
for (IIndexBinding binding : ibs) {
|
for (IIndexBinding binding : ibs) {
|
||||||
|
@ -392,9 +401,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(CoreException ce) {
|
} catch(CoreException ce) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(ce);
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
CCorePlugin.log(ie);
|
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
@ -406,7 +413,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||||
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
|
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return new ITypeReference[0];
|
||||||
|
}
|
||||||
|
try {
|
||||||
char[] cfn= fqn[0].toCharArray();
|
char[] cfn= fqn[0].toCharArray();
|
||||||
IIndexMacro[] ibs = index.findMacros(cfn, IndexFilter.ALL_DECLARED, new NullProgressMonitor());
|
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
|
// 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) {
|
} catch(CoreException ce) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(ce);
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
CCorePlugin.log(ie);
|
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* 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
|
||||||
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.provider;
|
package org.eclipse.cdt.internal.core.index.provider;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -20,6 +19,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.index.provider.IIndexProvider;
|
import org.eclipse.cdt.core.index.provider.IIndexProvider;
|
||||||
import org.eclipse.cdt.core.index.provider.IReadOnlyPDOMProvider;
|
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 {
|
private void processCandidate(Map<String, IIndexFragment> id2fragment, IIndexFragment candidate) throws InterruptedException, CoreException {
|
||||||
String cid= null, csver= null, cformatID= null;
|
String cid= null, csver= null, cformatID= null;
|
||||||
|
candidate.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
candidate.acquireReadLock();
|
|
||||||
cid= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
|
cid= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
|
||||||
csver= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
|
csver= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
|
||||||
cformatID= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID);
|
cformatID= candidate.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID);
|
||||||
|
@ -218,8 +219,8 @@ public final class IndexProviderManager implements IElementChangedListener {
|
||||||
if(getCurrentlySupportedVersionRangeForFormat(cformatID).isIncluded(cver)) {
|
if(getCurrentlySupportedVersionRangeForFormat(cformatID).isIncluded(cver)) {
|
||||||
if(existing != null) {
|
if(existing != null) {
|
||||||
String esver= null, eformatID= null;
|
String esver= null, eformatID= null;
|
||||||
|
existing.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
existing.acquireReadLock();
|
|
||||||
esver= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
|
esver= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION);
|
||||||
eformatID= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID);
|
eformatID= existing.getProperty(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -302,8 +302,8 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
|
IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
|
||||||
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
|
||||||
IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
|
IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
|
||||||
for(int i=0; i<bindings.length; i++) {
|
for(int i=0; i<bindings.length; i++) {
|
||||||
if (i % 0x1000 == 0 && monitor.isCanceled()) {
|
if (i % 0x1000 == 0 && monitor.isCanceled()) {
|
||||||
|
|
|
@ -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
|
* Rapperswil, University of applied sciences 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
|
||||||
|
@ -59,11 +59,15 @@ public class DefinitionFinder {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
pdomref= index.findDefinitions(bind);
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
|
IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
|
||||||
CUIPlugin.log(status);
|
CUIPlugin.log(status);
|
||||||
} finally {
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
pdomref= index.findDefinitions(bind);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Rapperswil, University of applied sciences 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
|
||||||
|
@ -151,7 +151,13 @@ public class TranslationUnitHelper {
|
||||||
IIndex index;
|
IIndex index;
|
||||||
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
|
||||||
index= CCorePlugin.getIndexManager().getIndex(projects);
|
index= CCorePlugin.getIndexManager().getIndex(projects);
|
||||||
index.acquireReadLock();
|
try {
|
||||||
|
index.acquireReadLock();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// no lock was acquired
|
||||||
|
index= null;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* 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
|
||||||
|
@ -409,6 +409,8 @@ public class NewClassWizardUtil {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
return SEARCH_MATCH_ERROR;
|
return SEARCH_MATCH_ERROR;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return SEARCH_MATCH_NOTFOUND;
|
||||||
}
|
}
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
return SEARCH_MATCH_ERROR;
|
return SEARCH_MATCH_ERROR;
|
||||||
|
|
Loading…
Add table
Reference in a new issue