You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2022/11/29 19:08:41 UTC
[sis] 01/03: Avoid a NumberFormatException in the wizard when installing JavaFX 19.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit 333791293f1d75a2984156a8bd7c29ca42c704e0
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue Nov 29 11:29:26 2022 +0100
Avoid a NumberFormatException in the wizard when installing JavaFX 19.
---
.../org/apache/sis/internal/setup/FXFinder.java | 29 ++++++++++++++--------
.../apache/sis/internal/setup/package-info.java | 2 +-
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java
index a2735d45d0..0303ecc755 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/FXFinder.java
@@ -34,7 +34,7 @@ import java.util.zip.ZipFile;
* This is used when JavaFX cannot be found on the classpath.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.1
+ * @version 1.3
* @since 1.1
* @module
*/
@@ -276,7 +276,10 @@ public final class FXFinder {
* <pre>javafx-sdk-<version>/lib/javafx.controls.jar</pre>
*
* If the file seems valid, {@code null} is returned.
- * Otherwise an error message is HTML is returned.
+ * Otherwise an error message in HTML is returned.
+ *
+ * @param file path to the zip file.
+ * @return {@code null} on success, otherwise error message in HTML.
*/
static String checkZip(final File file) throws IOException {
try (ZipFile zip = new ZipFile(file)) {
@@ -287,15 +290,21 @@ public final class FXFinder {
final String basedir = entry.getName();
if (basedir.startsWith(JAVAFX_DIRECTORY_PREFIX)) {
final int start = JAVAFX_DIRECTORY_PREFIX.length();
- int end = basedir.indexOf('.', start);
- if (end < start) end = basedir.length();
- final int version = Integer.parseInt(basedir.substring(start, end));
- if (version < JAVAFX_VERSION) {
- return "<html>Apache SIS requires JavaFX version " + JAVAFX_VERSION + " or later. "
- + "The given file contains JavaFX version " + version + ".</html>";
+ int end = start;
+ while (end < basedir.length()) {
+ final char c = basedir.charAt(end);
+ if (c < '0' || c > '9') break;
+ end++;
}
- if (zip.getEntry(basedir + JAVAFX_LIB_DIRECTORY + '/' + JAVAFX_SENTINEL_FILE) != null) {
- return null; // Valid file.
+ if (end > start) {
+ final int version = Integer.parseInt(basedir.substring(start, end));
+ if (version < JAVAFX_VERSION) {
+ return "<html>Apache SIS requires JavaFX version " + JAVAFX_VERSION + " or later. "
+ + "The given file contains JavaFX version " + version + ".</html>";
+ }
+ if (zip.getEntry(basedir + JAVAFX_LIB_DIRECTORY + '/' + JAVAFX_SENTINEL_FILE) != null) {
+ return null; // Valid file.
+ }
}
}
break;
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/package-info.java b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/package-info.java
index 0b9d164cb0..298a097bf7 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/package-info.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/package-info.java
@@ -22,7 +22,7 @@
* may change in incompatible ways in any future version without notice.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 1.1
+ * @version 1.3
* @since 1.1
* @module
*/