Skip to content

error in locale processing #139

@tsaitgaist

Description

@tsaitgaist

Describe the bug (mandatory)
Can't start ns-usbloader. It exits with the following main error (detail below):

...
Caused by: java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 2
...
	at nsusbloader.AppPreferences.<init>(AppPreferences.java:35)

Information about environment (mandatory):

  • OS: Linux Arch amd64
  • Java version: OpenJDK Runtime Environment (build 19.0.2+7), the error also happens with java 11 (with slightly different message)
  • ns-usbloader: 7.0

Steps to reproduce
Steps to reproduce the behavior:

  1. start ns-usbloader in console
  2. See error

Expected behavior
ns-usbloader starts and GUI appears

Screenshots and/or information from application log
complete error log:

Mar 16, 2023 10:21:48 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @7f63425a'
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
	at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.ExceptionInInitializerError
	at nsusbloader.NSLMain.start(NSLMain.java:43)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
	... 1 more
Caused by: java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 2
	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
	at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
	at java.base/java.lang.String.substring(String.java:2715)
	at java.base/java.lang.String.substring(String.java:2688)
	at nsusbloader.AppPreferences.<init>(AppPreferences.java:35)
	at nsusbloader.AppPreferences.<clinit>(AppPreferences.java:25)
	... 10 more

Additional context

the corresponding code line is:

        this.locale = new Locale(localeCode.substring(0, 2), localeCode.substring(3));

my localeCode is "en". There is no country information.
thus localeCode.substring(3) causes an out of index.
the code could check for the length, and ceate a local without country when no present.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions