Minimize # of threads for fetching boot versions from maven central
This commit is contained in:
@@ -311,13 +311,13 @@ public class ORAstUtils {
|
||||
ctx = parseContext;
|
||||
}
|
||||
List<CompilationUnit> cus = Collections.emptyList();
|
||||
long start = System.currentTimeMillis();
|
||||
// long start = System.currentTimeMillis();
|
||||
synchronized (parser) {
|
||||
cus = parser.parseInputs(inputs, null, ctx);
|
||||
}
|
||||
log.info("Rewrite parser: " + (System.currentTimeMillis() - start));
|
||||
// log.info("Rewrite parser: " + (System.currentTimeMillis() - start));
|
||||
List<J.CompilationUnit> finalCus = new ArrayList<>(cus.size());
|
||||
start = System.currentTimeMillis();
|
||||
// start = System.currentTimeMillis();
|
||||
for (CompilationUnit cu : cus) {
|
||||
J.CompilationUnit newCu = (J.CompilationUnit) new UpdateSourcePositions().getVisitor().visit(cu, ctx);
|
||||
if (newCu == null) {
|
||||
@@ -326,7 +326,7 @@ public class ORAstUtils {
|
||||
finalCus.add(newCu);
|
||||
}
|
||||
}
|
||||
log.info("Positions Update: " + (System.currentTimeMillis() - start));
|
||||
// log.info("Positions Update: " + (System.currentTimeMillis() - start));
|
||||
return finalCus;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.validation.generations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
@@ -44,13 +45,19 @@ public class CachedBootVersionsFromMavenCentral {
|
||||
@Override
|
||||
public List<Version> load(String key) throws Exception {
|
||||
for (int i = 0; i < ATTEMPTS_NUMBER; i++) {
|
||||
CompletableFuture<List<Version>> future = null;
|
||||
try {
|
||||
return getFuture().get(RESPONSE_WAIT_TIME_MS, TimeUnit.MILLISECONDS);
|
||||
future = getFuture();
|
||||
return future.get(RESPONSE_WAIT_TIME_MS, TimeUnit.MILLISECONDS);
|
||||
} catch (ExecutionException | TimeoutException e) {
|
||||
// ignore exception - ask maven central again
|
||||
if (future != null) {
|
||||
future.cancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Exception("Failed to fetch versions from Maven Central after " + ATTEMPTS_NUMBER + " tries.");
|
||||
log.error("Failed to fetch versions from Maven Central after " + ATTEMPTS_NUMBER + " tries.");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user