developersu / ns-usbloader

Awoo Installer and GoldLeaf uploader of the NSPs (and other files), RCM payload injector, application for split/merge files.
GNU General Public License v3.0
1.77k stars 116 forks source link

error in locale processing #139

Closed tsaitgaist closed 1 year ago

tsaitgaist commented 1 year ago

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):

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 commented 1 year ago

Thank you for detailed report!

developersu commented 1 year ago

Fixed version, in case you need it ;)

hypnotiger commented 1 year ago

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 commented 11 months ago

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!