nexus-public
nexus-public copied to clipboard
Fix maven2 path has double hash extension or .asc mix with hash extension parse error
The url resource for test:
https://repo1.maven.org/maven2/com/netflix/spectator/spectator-ext-jvm/0.103.0/spectator-ext-jvm-0.103.0.module.md5.asc
Here is the exception log:
2020-10-28 10:57:58,623+0800 WARN [qtp716471188-527] *UNKNOWN org.sonatype.nexus.repository.httpbridge.internal.ViewServlet - Failure servicing: GET /maven2/com/netflix/spectator/spectator-ext-jvm/0.103.0/spectator-ext-jvm-0.103.0.module.md5.asc java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1967) at org.sonatype.nexus.repository.maven.MavenPath.subordinateOf(MavenPath.java:288) at org.sonatype.nexus.repository.maven.MavenPath.main(MavenPath.java:265) at org.sonatype.nexus.repository.maven.internal.Maven2MavenPathParser.isRepositoryMetadata(Maven2MavenPathParser.java:70) at org.sonatype.nexus.repository.maven.internal.orient.MavenProxyFacet.getCacheController(MavenProxyFacet.java:79) at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.fetch(ProxyFacetSupport.java:440) at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.fetch(ProxyFacetSupport.java:402) at org.sonatype.nexus.repository.maven.internal.orient.MavenProxyFacet.fetch(MavenProxyFacet.java:74) at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.doGet(ProxyFacetSupport.java:269) at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.lambda$1(ProxyFacetSupport.java:245) at org.sonatype.nexus.common.io.CooperatingFuture.performCall(CooperatingFuture.java:122) at org.sonatype.nexus.common.io.CooperatingFuture.call(CooperatingFuture.java:64) at org.sonatype.nexus.common.io.ScopedCooperationFactorySupport$ScopedCooperation.cooperate(ScopedCooperationFactorySupport.java:99)
In my opinion, this pr may be the smallest change of code, but maybe not the best solution.
If you have some other ideas, welcome to discuss with me.
I also create a issue at MVN JIRA: https://issues.sonatype.org/browse/NEXUS-25645
Thanks for review.
to note for any devs that have a look at this - @EdmondFrank has signed the CLA already on another PR