Skip to content

Commit

Permalink
Fix error in JDK URL regex
Browse files Browse the repository at this point in the history
Java regex matches the full string by default, so we need
to prepend with .*, and it needs to be non-greedy so that
the optional .tar portion also matches as desired.
  • Loading branch information
ctrueden committed Nov 19, 2024
1 parent 2ac04d4 commit b7cb938
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/scijava/launcher/Java.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public static void upgrade(BiConsumer<String, Double> subscriber)

// Create a temp file to house the downloaded Java archive.
String prefix = Java.class.getName() + "-";
Matcher m = Pattern.compile("((\\.tar)?\\.[^.]*)$").matcher(javaLink);
Matcher m = Pattern.compile(".*?((\\.tar)?\\.[^.]*)$").matcher(javaLink);
String suffix = m.matches() ? m.group(1) : null;
File tmpArchive = Files.createTempFile(prefix, suffix).toFile();
tmpArchive.deleteOnExit();
Expand Down

0 comments on commit b7cb938

Please sign in to comment.