Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in locale processing #139

Closed
tsaitgaist opened this issue Mar 16, 2023 · 4 comments
Closed

error in locale processing #139

tsaitgaist opened this issue Mar 16, 2023 · 4 comments
Assignees

Comments

@tsaitgaist
Copy link

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.

@developersu
Copy link
Owner

Thank you for detailed report!

@developersu
Copy link
Owner

Fixed version, in case you need it ;)

@isatsam
Copy link

isatsam commented Jul 4, 2023

This issue is present for me as well in the 7.0 version that's posted in Releases, and I have a similar setup (Arch, Java 20.0.1+9, no country in locales). Could this fix be merged into the main .jar file sometime? Although - thanks a lot for the fix anyways!

@developersu
Copy link
Owner

Yeah, it could, it's already merged in source code level. I'm just lazy to create new release..
(There won't be any difference between release version and the one that I mentioned above, in case you're not sure in build stability)

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants