From 82bcb214bc5803f425dd24fa23f50c76378ef05a Mon Sep 17 00:00:00 2001 From: Christian W. Damus Date: Tue, 28 Jul 2015 11:34:59 -0400 Subject: Bug 473154: FileNotFoundException in LocalFile.openInputStream (369) https://bugs.eclipse.org/bugs/show_bug.cgi?id=473154 Ensure that we only attempt to index files that are synchronized as far as the workspace is concerned. Includes a JUnit test that fails without the fix on detection of the same exception logged as in the original bug report. (cherry picked from commit e334737bc2fe21da7ab91bfc87fcd49944275bdd) Change-Id: Idf211d87b7c59cea73d399419e8dcabede66dde8 --- .../papyrus/infra/emf/resource/index/WorkspaceModelIndex.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins/infra/emf') diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java index 8a5ace5abb3..45e6ba795b6 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java @@ -284,8 +284,13 @@ public class WorkspaceModelIndex { boolean match(IFile file) { boolean result = false; - // Don't even attempt to match the content type if the file extension doesn't match - if (file.isAccessible() && ((fileExtensions == null) || fileExtensions.contains(file.getFileExtension()))) { + // Don't even attempt to match the content type if the file extension doesn't match. + // And if it's not synchronized, don't attempt to do anything with it. We'll get it + // later when it is synchronized + if (file.isAccessible() + && ((fileExtensions == null) || fileExtensions.contains(file.getFileExtension())) + && file.isSynchronized(IResource.DEPTH_ZERO)) { + IContentType[] contentTypes = contentTypeService.getContentTypes(file); if (contentTypes != null) { for (int i = 0; (i < contentTypes.length) && !result; i++) { -- cgit v1.2.3