-
Notifications
You must be signed in to change notification settings - Fork 519
Fix URISyntaxException in MavenPomDownloader for unresolved version placeholders #7313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -558,6 +558,16 @@ public Pom download(GroupArtifactVersion gav, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gav = resolveNamedVersion(gav, containingPom, repositories, ctx); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String versionMaybeDatedSnapshot = datedSnapshotVersion(gav, containingPom, repositories, ctx); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gav = handleSnapshotTimestampVersion(gav); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If the version still contains unresolved property placeholders (e.g. ${revision}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // downloading from any repository will never succeed and would cause URISyntaxException | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // due to illegal '{' / '}' characters in the constructed URI. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //noinspection DataFlowIssue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (gav.getVersion().contains("${")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new MavenDownloadingException("Unable to download POM " + gav + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ". Version contains unresolved property placeholder.", null, originalGav); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+563
to
+564
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copying a few interesting patterns here: rewrite/rewrite-gradle/src/main/java/org/openrewrite/gradle/internal/AddDependencyVisitor.java Lines 291 to 292 in 24b27e1
rewrite/rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeDependencyVersion.java Lines 782 to 786 in a636e5c
rewrite/rewrite-gradle/src/main/java/org/openrewrite/gradle/RemoveRedundantDependencyVersions.java Lines 192 to 193 in b8612b5
rewrite/rewrite-maven/src/main/java/org/openrewrite/maven/RemoveRedundantDependencyVersions.java Lines 288 to 289 in e0d7e9a
rewrite/rewrite-maven/src/main/java/org/openrewrite/maven/UpgradeDependencyVersion.java Lines 217 to 218 in 22fd6f5
rewrite/rewrite-maven/src/main/java/org/openrewrite/maven/trait/MavenDependency.java Lines 111 to 124 in de200b2
The |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterable<MavenRepository> normalizedRepos = distinctNormalizedRepositories(repositories, containingPom, gav.getVersion()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Timer.Sample sample = Timer.start(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1108,7 +1108,7 @@ void shouldThrowExceptionForModulesInModulesWithNoRightProperty() { | |
|
|
||
| var downloader = new MavenPomDownloader(pomsByPath, ctx); | ||
|
|
||
| assertThrows(IllegalArgumentException.class, () -> downloader.download(gav, Objects.requireNonNull(pom.getParent()).getRelativePath(), resolvedPom, singletonList(nonexistentRepo))); | ||
| assertThrows(MavenDownloadingException.class, () -> downloader.download(gav, Objects.requireNonNull(pom.getParent()).getRelativePath(), resolvedPom, singletonList(nonexistentRepo))); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test & assertion on an IllegalArgumentException was explicitly added in |
||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -1197,9 +1197,10 @@ void emptyRelativePathSkipsLocalParentLookup() { | |
| assertDoesNotThrow(() -> downloader.download(requestedGav, null, resolvedPom, singletonList(nonexistentRepo))); | ||
|
|
||
| // With empty relativePath (<relativePath/>), step 3 is skipped entirely. | ||
| // Since the parent can't be found by GAV match either, and the remote | ||
| // repo doesn't exist, download fails — proving local lookup was skipped. | ||
| assertThrows(Exception.class, | ||
| // Since the parent can't be found by GAV match either, the version still | ||
| // contains an unresolved placeholder, so download throws MavenDownloadingException | ||
| // instead of URISyntaxException from URI.create(). | ||
| assertThrows(MavenDownloadingException.class, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion was added in |
||
| () -> downloader.download(requestedGav, "", resolvedPom, singletonList(nonexistentRepo))); | ||
| } | ||
|
|
||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.