TerminalOutput.pathToMaven throws StringIndexOutOfBoundsException
- Dominant language
- Java
- Stars
- 3.5k
- Forks
- 250
- Avg merge
- 16h 22m
- Merged PRs (30d)
- 36
Description
Steps to reproduce:
```
git clone git@github.com:quarkiverse/quarkus-langchain4j.git
cd quarkus-langchain4j
git reset --hard 177efc97b49823ad747a87766ea1e1d0c2b71ef6
mvnd --stop
mvnd -v
Apache Maven Daemon (mvnd) 1.0-m8 linux-amd64 native client (0f4bdb6df5e74453d8d558d292789da4e66a7933)Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jansi.linux.LinuxNativePty
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: /home/ppalaga/.sdkman/candidates/mvnd/1.0-m8-m39/mvn
Java version: 17.0.9, vendor: Eclipse Adoptium, runtime: /home/ppalaga/.sdkman/candidates/java/17.0.9-tem
Default locale: en_IE, platform encoding: UTF-8
OS name: "linux", version: "6.4.11-200.fc38.x86_64", arch: "amd64", family: "unix"
rm -Rf /tmp/empty-local-maven-repo
mvnd clean install -DskipTests -Dquarkus.build.skip -Dmaven.repo.local=/tmp/empty-local-maven-repo
...
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 17
at java.base@17.0.6/java.lang.StringLatin1.charAt(StringLatin1.java:48)
at java.base@17.0.6/java.lang.String.charAt(String.java:1513)
at org.mvndaemon.mvnd.common.logging.TerminalOutput.pathToMaven(TerminalOutput.java:724)
at org.mvndaemon.mvnd.common.logging.TerminalOutput.formatTransfers(TerminalOutput.java:697)
at org.mvndaemon.mvnd.common.logging.TerminalOutput.addProjectLine(TerminalOutput.java:810)
at org.mvndaemon.mvnd.common.logging.TerminalOutput.update(TerminalOutput.java:615)
at org.mvndaemon.mvnd.common.logging.TerminalOutput.accept(TerminalOutput.java:217)
at org.mvndaemon.mvnd.client.DefaultClient.execute(DefaultClient.java:366)
at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:161)
```
The daemon log contains the following lines that cause the issue in the client:
```
15:23:09.559 I Dispatch message: TransferInitiated{projectId=quarkus-langchain4j-parent, requestType=0, repositoryId='central', repositoryUrl='https://repo.maven.apache.org/maven2/', resourceName='io/quarkus/quarkus-jackson/3.8.2/quarkus-jackson-3.8.2', contentLength=-1, transferredBytes=0, exception='null'}
15:23:09.559 I Dispatch message: ProjectLogMessage{projectId='quarkus-langchain4j-parent', message='[[1;34mINFO[m] Downloading from central: https://repo.maven.apache.org/maven2/io/quarkus/quarkus-jackson/3.8.2/quarkus-jackson-3.8.2'}
```
Normally the artifact URL has an extension, such as `.pom` or `.jar`. There is no such in `https://repo.maven.apache.org/maven2/io/quarkus/quarkus-jackson/3.8.2/quarkus-jackson-3.8.2` above.
I have no idea where it is coming from.
In any case, we should make the `TerminalOutput.pathToMaven()` method more robust so that it does not fail on this kind of input.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at TerminalOutput.pathToMaven(), identified at line 724 in the stack trace, and inspect how it handles the artifact URL without a file extension. Reproduce the mvnd build with the shown URL and verify that formatting the transfer no longer throws 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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100