sonatype-nexus-community / nexus-repository-apk

Eclipse Public License 1.0
42 stars 24 forks source link

Failure servicing: GET (only lua5.3-libs-5.3.5-r2.apk) #4

Closed adrianp-sti closed 4 years ago

adrianp-sti commented 4 years ago

Hi,

I have v0.0.1 of the plugin installed on Nexus 3.19.1-01. I've setup two .apk repositories for 3.10 (main and community) for x86_64 clients. On some basic testing it seems to be going fine for the majority of .apks but one is causing a stack trace to be generated. It looks like the plugin has problems with lua5.3-libs-5.3.5-r2.apk. I can't find others that are causing the same issue but haven't heavily tested. Top few lines of the stack trace is below - I have the full one if needed.

thanks,

adrian.

2019-11-09 12:26:24,159+0000 WARN [qtp1574709515-450] *UNKNOWN org.sonatype.nexus.repository.httpbridge.internal.ViewServlet - Failure servicing: GET /repository/alpine-3.10-main/x86_64/lua5.3-libs-5.3.5-r2.apk java.lang.StringIndexOutOfBoundsException: String index out of range: 11 at java.lang.String.substring(String.java:1963) at org.sonatype.nexus.plugins.apk.internal.ApkPathUtils.name(ApkPathUtils.java:89) at org.sonatype.nexus.plugins.apk.internal.ApkProxyFacetImpl.getCachedContent(ApkProxyFacetImpl.java:66) at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.maybeGetCachedContent(ProxyFacetSupport.java:369)

adrianp-sti commented 4 years ago

I'm testing this at the moment as it seems to have resolved the issue:

--- nexus-repository-apk/src/main/java/org/sonatype/nexus/plugins/apk/internal/ApkPathUtils.java.orig
+++ nexus-repository-apk/src/main/java/org/sonatype/nexus/plugins/apk/internal/ApkPathUtils.java
@@ -78,7 +78,7 @@
   }

   public String name(final TokenMatcher.State state) {
-    Pattern pattern = Pattern.compile("([a-zA-Z][a-zA-Z0-9]+-)+");
+    Pattern pattern = Pattern.compile("([a-zA-Z][a-zA-Z0-9.]+-)+");

     String filename = match(state, "filename");
     Matcher matcher = pattern.matcher(filename);
DarthHater commented 4 years ago

Very cool that you found the fix! Send a PR on over @adrianp-sti !

adrianp-sti commented 4 years ago

Found a few more use cases:

Once I've got them all done I'll send across another pull-up

adrianp-sti commented 4 years ago

Updated pull up in #6

bhamail commented 4 years ago

Fixed in #6