Skip to content

Commit

Permalink
Some more logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Jan 18, 2023
1 parent 533d41f commit 91bd093
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
public class MavenLemminxWorkspaceReader implements WorkspaceReader {

private static final int POLLING_INTERVAL = 10;
private static final int POLLING_INTERVAL = 30;

private static final Logger LOGGER = Logger.getLogger(MavenLemminxExtension.class.getName());

Expand All @@ -65,6 +65,7 @@ private ResolveArtifactsAndPopulateWorkspaceRunnable(File pomFile) {
public void run() {
// already processed, don't repeat operation
if (!workspaceArtifacts.containsValue(pomFile)) {
LOGGER.finest("Trying to add " + pomFile + "to workspace...");
skipFlushBeforeResult.set(true); // avoid deadlock as building project will go through this workspace reader
Optional<MavenProject> snapshotProject = Optional.empty();
try {
Expand All @@ -80,7 +81,9 @@ public void run() {
while (project != null) {
File pom = project.getFile();
if (toProcess.contains(pom)) {
workspaceArtifacts.put(new DefaultArtifact(project.getGroupId(), project.getArtifactId(), null, project.getVersion()), pom);
DefaultArtifact artifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), null, project.getVersion());
workspaceArtifacts.put(artifact, pom);
LOGGER.finest("Registered" + artifact + " -> " + pom + " into workspace...");
}
propagateProcessed(pom);
project = project.getParent();
Expand All @@ -104,14 +107,17 @@ public void run() {
if (groupId.isPresent() && !groupId.get().contains("$") && //
artifactId.isPresent() && !artifactId.get().contains("$") &&
version.isPresent() && !version.get().contains("$")) {
workspaceArtifacts.put(new DefaultArtifact(groupId.get(), artifactId.get(), null, version.get()), pomFile);
DefaultArtifact artifact = new DefaultArtifact(groupId.get(), artifactId.get(), null, version.get());
workspaceArtifacts.put(artifact, pomFile);
LOGGER.finest("Registered" + artifact + " -> " + pomFile + " into workspace...");
}
});
} catch (IOException ex) {
LOGGER.fine(ex.getMessage());
}
});
}
LOGGER.finest("Done adding " + pomFile + "to workspace...");
// ensure we remove it from further processing even in case no MavenProject can be built
propagateProcessed(pomFile);
}
Expand Down Expand Up @@ -182,13 +188,15 @@ public File findArtifact(Artifact artifact) {
.findAny()
.or(() -> {
if (skipFlushBeforeResult.get() != Boolean.TRUE) {
LOGGER.finest("Waiting for " + projectKey + " to be avilable; processing workspace in the meantime...");
while (!toProcess.isEmpty() && getCurrentWorkspaceArtifact(projectKey).isEmpty()) {
try {
Thread.sleep(POLLING_INTERVAL);
} catch (InterruptedException e) {
LOGGER.severe(e.getMessage());
}
}
LOGGER.finest("Done waiting from " + projectKey + ". Either found, or all workspace processed.");
}
return getCurrentWorkspaceArtifact(projectKey);
}).orElse(null);
Expand All @@ -204,13 +212,15 @@ private Optional<File> getCurrentWorkspaceArtifact(String projectKey) {
@Override
public List<String> findVersions(Artifact artifact) {
if (skipFlushBeforeResult.get() != Boolean.TRUE) {
LOGGER.finest("Lookup available versions for " + artifact + "; processing workspace in the meantime...");
while (!toProcess.isEmpty()) {
try {
Thread.sleep(POLLING_INTERVAL);
} catch (InterruptedException e) {
LOGGER.severe(e.getMessage());
}
}
LOGGER.finest("Workspace processing complete");
}
String key = ArtifactUtils.versionlessKey(artifact.getGroupId(), artifact.getArtifactId());
SortedSet<String> res = new TreeSet<>(Comparator.reverseOrder());
Expand Down

0 comments on commit 91bd093

Please sign in to comment.