From b7cb9385e7d7059201674fab3e5d2429d74f5c54 Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 19 Nov 2024 17:02:07 -0600 Subject: [PATCH] Fix error in JDK URL regex 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. --- src/main/java/org/scijava/launcher/Java.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/scijava/launcher/Java.java b/src/main/java/org/scijava/launcher/Java.java index cf955fc..d3a0564 100644 --- a/src/main/java/org/scijava/launcher/Java.java +++ b/src/main/java/org/scijava/launcher/Java.java @@ -300,7 +300,7 @@ public static void upgrade(BiConsumer 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();