apache / apache/maven-artifact-plugin
compare: getRepositoryFilename crashes on path without '/'
- Dominant language
- Java
- Stars
- 14
- Forks
- 23
- Avg merge
- 1h 27m
- Merged PRs (30d)
- 8
Description
`CompareMojo.getRepositoryFilename(Artifact)` (lines 328-331):
```java
String path = session.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(a);
return path.substring(path.lastIndexOf('/'));
```
`path.substring(path.lastIndexOf('/'))` throws `StringIndexOutOfBoundsException` if the local-repo layout returns a filename without a `/` separator (root-based `pom` layout in some configurations). Also a negative index propagates as a confusing runtime exception rather than a clean `MojoExecutionException`.
Suggested fix: guard `lastIndexOf('/')` and use `Path`-based extraction.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at CompareMojo.getRepositoryFilename(Artifact), lines 328-331, and inspect how the local repository manager supplies a path for a root-based pom layout. Verify handling for a filename without '/' and for a negative lookup, then run the project's existing tests; the issue does not name a specific test file. Done means these cases no longer produce a confusing StringIndexOutOfBoundsException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100