Skip to content

Commit 3b67119

Browse files
committed
Log exceptions when indexing #1303
Exceptions while creating the index are logged as errors and exceptions when saving the index are logged as information. Contributes to #1303
1 parent 1863250 commit 3b67119

File tree

4 files changed

+6
-24
lines changed

4 files changed

+6
-24
lines changed

org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*******************************************************************************/
1414
package org.eclipse.jdt.internal.core.search.indexing;
1515

16-
import static org.eclipse.jdt.internal.core.JavaModelManager.trace;
17-
1816
import java.io.IOException;
1917
import java.net.URI;
2018
import java.util.HashSet;
@@ -36,7 +34,6 @@
3634
import org.eclipse.jdt.internal.core.ClasspathEntry;
3735
import org.eclipse.jdt.internal.core.JavaProject;
3836
import org.eclipse.jdt.internal.core.index.Index;
39-
import org.eclipse.jdt.internal.core.search.processing.JobManager;
4037
import org.eclipse.jdt.internal.core.util.Util;
4138

4239
public class IndexAllProject extends IndexRequest {
@@ -230,9 +227,7 @@ public boolean visit(IResourceProxy proxy) throws CoreException {
230227
// request to save index when all cus have been indexed... also sets state to SAVED_STATE
231228
this.manager.request(new SaveIndex(this.containerPath, this.manager));
232229
} catch (CoreException | IOException e) {
233-
if (JobManager.VERBOSE) {
234-
trace("-> failed to index " + this.project + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$
235-
}
230+
Util.log(e, "Failed to index " + this.project + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
236231
this.manager.removeIndex(this.containerPath);
237232
return false;
238233
} finally {

org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*******************************************************************************/
1414
package org.eclipse.jdt.internal.core.search.indexing;
1515

16-
import static org.eclipse.jdt.internal.core.JavaModelManager.trace;
17-
1816
import java.io.IOException;
1917
import java.net.URI;
2018
import org.eclipse.core.filesystem.EFS;
@@ -27,7 +25,6 @@
2725
import org.eclipse.core.runtime.IProgressMonitor;
2826
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
2927
import org.eclipse.jdt.internal.core.index.Index;
30-
import org.eclipse.jdt.internal.core.search.processing.JobManager;
3128
import org.eclipse.jdt.internal.core.util.Util;
3229

3330
public class IndexBinaryFolder extends IndexRequest {
@@ -137,9 +134,7 @@ public boolean visit(IResourceProxy proxy) throws CoreException {
137134
// request to save index when all class files have been indexed... also sets state to SAVED_STATE
138135
this.manager.request(new SaveIndex(this.containerPath, this.manager));
139136
} catch (CoreException | IOException e) {
140-
if (JobManager.VERBOSE) {
141-
trace("-> failed to index " + this.folder + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$
142-
}
137+
Util.log(e, "Failed to index " + this.folder + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
143138
this.manager.removeIndex(this.containerPath);
144139
return false;
145140
} finally {

org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313
*******************************************************************************/
1414
package org.eclipse.jdt.internal.core.search.indexing;
1515

16-
import static org.eclipse.jdt.internal.core.JavaModelManager.trace;
17-
1816
import java.io.IOException;
1917
import org.eclipse.core.resources.IProject;
2018
import org.eclipse.core.runtime.IPath;
2119
import org.eclipse.core.runtime.IProgressMonitor;
2220
import org.eclipse.core.runtime.Path;
2321
import org.eclipse.jdt.internal.core.index.Index;
24-
import org.eclipse.jdt.internal.core.search.processing.JobManager;
2522
import org.eclipse.jdt.internal.core.util.Util;
2623

2724
class RemoveFolderFromIndex extends IndexRequest {
@@ -65,9 +62,7 @@ public boolean execute(IProgressMonitor progressMonitor) {
6562
}
6663
}
6764
} catch (IOException e) {
68-
if (JobManager.VERBOSE) {
69-
trace("-> failed to remove " + this.folderPath + " from index because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$
70-
}
65+
Util.log(e, "Failed to remove " + this.folderPath + " from index: " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
7166
return false;
7267
} finally {
7368
monitor.exitRead(); // free read lock

org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
*******************************************************************************/
1414
package org.eclipse.jdt.internal.core.search.indexing;
1515

16-
import static org.eclipse.jdt.internal.core.JavaModelManager.trace;
17-
1816
import java.io.IOException;
1917
import org.eclipse.core.runtime.IPath;
2018
import org.eclipse.core.runtime.IProgressMonitor;
19+
import org.eclipse.core.runtime.Status;
2120
import org.eclipse.jdt.internal.core.index.Index;
22-
import org.eclipse.jdt.internal.core.search.processing.JobManager;
21+
import org.eclipse.jdt.internal.core.util.Util;
2322

2423
/*
2524
* Save the index of a project.
@@ -43,9 +42,7 @@ public boolean execute(IProgressMonitor progressMonitor) {
4342
monitor.enterWrite(); // ask permission to write
4443
this.manager.saveIndex(index);
4544
} catch (IOException e) {
46-
if (JobManager.VERBOSE) {
47-
trace("-> failed to save index " + this.containerPath + " because of the following exception:", e); //$NON-NLS-1$ //$NON-NLS-2$
48-
}
45+
Util.log(Status.warning("Failed to save index " + this.containerPath + ": " + e.getMessage(), e)); //$NON-NLS-1$ //$NON-NLS-2$
4946
return false;
5047
} finally {
5148
monitor.exitWrite(); // free write lock

0 commit comments

Comments
 (0)