Skip to content

Commit

Permalink
Fix edge case with property placeholders in repository uri. Fixes #2603
Browse files Browse the repository at this point in the history
  • Loading branch information
tkvangorder committed Jan 10, 2023
1 parent 1fb4406 commit 4c6baf1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Expand Up @@ -639,6 +639,14 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, @
if (repository.isKnownToExist()) {
return repository;
}

// If a repository URI contains an unresolved property placeholder, do not continue.
// There is also an edge case in which this condition is transient during `resolveParentPropertiesAndRepositoriesRecursively()`
// and therefore, we do not want to cache a null normalization result.
if (repository.getUri().contains("${")) {
return null;
}

String originalUrl = repository.getUri();
if ("file".equals(URI.create(originalUrl).getScheme())) {
return repository;
Expand Down
Expand Up @@ -65,6 +65,29 @@ void rangeVersion() {
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite/issues/2603")
void repositoryWithPropertyPlaceholder() {
rewriteRun(
pomXml(
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
</project>
"""
)
);
}

@Test
void invalidRange() {
assertThatExceptionOfType(MavenParsingException.class).isThrownBy(() ->
Expand Down

0 comments on commit 4c6baf1

Please sign in to comment.