Skip to content

Commit b23a335

Browse files
committed
Fix concurrency issue initializing ExtensionInfo in ApplicationDependencyResolver
1 parent 8a0e2be commit b23a335

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyResolver.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.io.IOException;
1111
import java.io.UncheckedIOException;
1212
import java.nio.file.Files;
13-
import java.nio.file.Path;
1413
import java.util.ArrayDeque;
1514
import java.util.ArrayList;
1615
import java.util.Collection;
@@ -668,8 +667,7 @@ void setFlags(byte walkingFlags) {
668667
setChildFlags(walkingFlags);
669668
}
670669

671-
private ExtensionDependency getExtensionDependencyOrNull()
672-
throws BootstrapDependencyProcessingException {
670+
private ExtensionDependency getExtensionDependencyOrNull() {
673671
if (ext != null) {
674672
return ext;
675673
}
@@ -719,11 +717,8 @@ Artifact getResolvedArtifact() {
719717

720718
/**
721719
* Collects information about the conditional dependencies and adds them to the processing queue.
722-
*
723-
* @throws BootstrapDependencyProcessingException in case of an error
724720
*/
725-
private void collectConditionalDependencies()
726-
throws BootstrapDependencyProcessingException {
721+
private void collectConditionalDependencies() {
727722
if (ext == null || ext.info.conditionalDeps.length == 0 || ext.conditionalDepsQueued) {
728723
return;
729724
}
@@ -782,27 +777,26 @@ private static boolean isFlagOn(byte flags, byte flag) {
782777
return (flags & flag) > 0;
783778
}
784779

785-
private ExtensionInfo getExtensionInfoOrNull(Artifact artifact, List<RemoteRepository> repos)
786-
throws BootstrapDependencyProcessingException {
780+
private ExtensionInfo getExtensionInfoOrNull(Artifact artifact, List<RemoteRepository> repos) {
787781
if (!artifact.getExtension().equals(ArtifactCoords.TYPE_JAR)) {
788782
return null;
789783
}
790-
final ArtifactKey extKey = getKey(artifact);
791-
ExtensionInfo ext = allExtensions.get(extKey);
792-
if (ext != null) {
793-
return ext == EXT_INFO_NONE ? null : ext;
794-
}
784+
ExtensionInfo ext = allExtensions.computeIfAbsent(getKey(artifact), k -> resolveExtensionInfo(artifact, repos));
785+
return ext == EXT_INFO_NONE ? null : ext;
786+
}
787+
788+
private ExtensionInfo resolveExtensionInfo(Artifact artifact, List<RemoteRepository> repos) {
795789
artifact = resolve(artifact, repos);
796-
final Path path = artifact.getFile().toPath();
797-
final Properties descriptor = PathTree.ofDirectoryOrArchive(path).apply(BootstrapConstants.DESCRIPTOR_PATH,
798-
ApplicationDependencyResolver::readExtensionProperties);
790+
final Properties descriptor = PathTree.ofDirectoryOrArchive(artifact.getFile().toPath())
791+
.apply(BootstrapConstants.DESCRIPTOR_PATH, ApplicationDependencyResolver::readExtensionProperties);
799792
if (descriptor == null) {
800-
allExtensions.put(extKey, EXT_INFO_NONE);
801-
return null;
793+
return EXT_INFO_NONE;
794+
}
795+
try {
796+
return new ExtensionInfo(artifact, descriptor, devMode);
797+
} catch (BootstrapDependencyProcessingException e) {
798+
throw new RuntimeException("Failed to collect extension information for " + artifact, e);
802799
}
803-
ext = new ExtensionInfo(artifact, descriptor, devMode);
804-
allExtensions.put(extKey, ext);
805-
return ext;
806800
}
807801

808802
private static Properties readExtensionProperties(PathVisit visit) {

0 commit comments

Comments
 (0)