diff --git a/vscode-extensions/commons/commons-java/.classpath b/vscode-extensions/commons/commons-java/.classpath
index 8433ca6cd..af1430be1 100644
--- a/vscode-extensions/commons/commons-java/.classpath
+++ b/vscode-extensions/commons/commons-java/.classpath
@@ -22,15 +22,5 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/vscode-extensions/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/JandexIndex.java b/vscode-extensions/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/JandexIndex.java
index e82bcd1b5..c713c0ac4 100644
--- a/vscode-extensions/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/JandexIndex.java
+++ b/vscode-extensions/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/JandexIndex.java
@@ -94,25 +94,42 @@ public class JandexIndex {
}
private static Optional indexJar(File file, IndexFileFinder indexFileFinder) {
- try {
File indexFile = indexFileFinder.findIndexFile(file);
if (indexFile != null) {
- if (indexFile.createNewFile()) {
- return Optional.of(JarIndexer
- .createJarIndex(file, new Indexer(), indexFile,
- false, false, true, System.out, System.err)
- .getIndex());
- } else {
- return Optional.of(new IndexReader(new FileInputStream(indexFile)).read());
+ try {
+ if (indexFile.createNewFile()) {
+ try {
+ return Optional.of(JarIndexer
+ .createJarIndex(file, new Indexer(), indexFile,
+ false, false, false, System.out, System.err)
+ .getIndex());
+ } catch (IOException e) {
+ Log.log("Failed to index '" + file + "'", e);
+ }
+ } else {
+ try {
+ return Optional.of(new IndexReader(new FileInputStream(indexFile)).read());
+ } catch (IOException e) {
+ Log.log("Failed to read index file '" + indexFile + "'. Creating new index file.", e);
+ if (indexFile.delete()) {
+ return indexJar(file, indexFileFinder);
+ } else {
+ Log.log("Failed to read index file '" + indexFile);
+ }
+ }
+ }
+ } catch (IOException e) {
+ Log.log("Unable to create index file '" + indexFile +"'");
}
} else {
- return Optional.of(JarIndexer
- .createJarIndex(file, new Indexer(), file.canWrite(), file.getParentFile().canWrite(), true)
- .getIndex());
+ try {
+ return Optional.of(JarIndexer
+ .createJarIndex(file, new Indexer(), file.canWrite(), file.getParentFile().canWrite(), false)
+ .getIndex());
+ } catch (IOException e) {
+ Log.log("Failed to index '" + file + "'", e);
+ }
}
- } catch (IOException e) {
- Log.log(e);
- }
return Optional.empty();
}
diff --git a/vscode-extensions/commons/commons-language-server/.classpath b/vscode-extensions/commons/commons-language-server/.classpath
index 8433ca6cd..af1430be1 100644
--- a/vscode-extensions/commons/commons-language-server/.classpath
+++ b/vscode-extensions/commons/commons-language-server/.classpath
@@ -22,15 +22,5 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java
index bff138460..52ea4578a 100644
--- a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java
+++ b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/MavenCore.java
@@ -257,10 +257,18 @@ public class MavenCore {
} catch (MavenException e) {
Log.log(e);
}
- return new File(System.getProperty(JAVA_IO_TMPDIR), jarFile.getName() + suffix);
+ return new File(getIndexFolder().toString(), jarFile.getName() + "-" + suffix + ".jdx");
}
public Optional getJavaIndexForJreLibs() {
return javaCoreIndex.get();
}
+
+ public File getIndexFolder() {
+ File folder = new File(System.getProperty(JAVA_IO_TMPDIR), "jandex");
+ if (!folder.isDirectory()) {
+ folder.mkdirs();
+ }
+ return folder;
+ }
}
diff --git a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java
index 775493466..074f59a5a 100644
--- a/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java
+++ b/vscode-extensions/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java
@@ -68,7 +68,7 @@ public class MavenProjectClasspath implements IClasspath {
}
private File findIndexFile(File jarFile) {
- return new File(System.getProperty(MavenCore.JAVA_IO_TMPDIR), jarFile.getName() + jarFile.lastModified());
+ return new File(maven.getIndexFolder().toString(), jarFile.getName() + "-" + jarFile.lastModified() + ".jdx");
}
}
diff --git a/vscode-extensions/commons/commons-util/.classpath b/vscode-extensions/commons/commons-util/.classpath
index 8433ca6cd..af1430be1 100644
--- a/vscode-extensions/commons/commons-util/.classpath
+++ b/vscode-extensions/commons/commons-util/.classpath
@@ -22,15 +22,5 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Log.java b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Log.java
index 109e664bf..cbd54166f 100644
--- a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Log.java
+++ b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Log.java
@@ -16,5 +16,13 @@ public class Log {
public static void log(Throwable e) {
logger.error("Error", e);
}
+
+ public static void log(String message, Throwable t) {
+ logger.error(message, t);
+ }
+
+ public static void log(String message) {
+ logger.error(message);
+ }
}
diff --git a/vscode-extensions/commons/commons-yaml/.classpath b/vscode-extensions/commons/commons-yaml/.classpath
index 8433ca6cd..af1430be1 100644
--- a/vscode-extensions/commons/commons-yaml/.classpath
+++ b/vscode-extensions/commons/commons-yaml/.classpath
@@ -22,15 +22,5 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/vscode-extensions/commons/language-server-test-harness/.classpath b/vscode-extensions/commons/language-server-test-harness/.classpath
index 8433ca6cd..af1430be1 100644
--- a/vscode-extensions/commons/language-server-test-harness/.classpath
+++ b/vscode-extensions/commons/language-server-test-harness/.classpath
@@ -22,15 +22,5 @@
-
-
-
-
-
-
-
-
-
-