Fix locale-dependent decimal formatting crashes in result tables#108
Open
BioGeek wants to merge 1 commit into
Open
Fix locale-dependent decimal formatting crashes in result tables#108BioGeek wants to merge 1 commit into
BioGeek wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a locale-dependent decimal formatting bug that can crash PDV result table rendering when the JVM default locale uses a comma as decimal separator.
PDV currently formats numeric values with DecimalFormat, then in several places parses the formatted string back with Double.valueOf(...). Under locales such as German, French, Dutch/Belgian, etc.,
DecimalFormat("#.0000").format(8.6407)returns8,6407, butDouble.valueOf("8,6407")throwsNumberFormatException.This was observed while opening InstaNovo results in PDV 2.4.0, but the root cause is not specific to InstaNovo. The same pattern exists in shared table models and other import/export/display paths.
Steps To Reproduce
SF_200217_U2OS_TiO2_HCD_OT_rep1.full.mzml.instanovo-1.2.2.transformer.model-instanovo-v1.2.0.denovo.greedy.beams-1.normalized-columns.csvSF_200217_U2OS_TiO2_HCD_OT_rep1.mzMLObserved Behavior
PDV shows an empty error dialog
and logs repeated table rendering exceptions like:
Expected Behavior
PDV should load and render result tables correctly regardless of the user’s JVM/system locale.
Fix
This PR adds a shared DecimalFormats helper that creates DecimalFormat instances with locale-independent decimal symbols using Locale.US.
It updates the affected GUI table models, importers, exporters, spectrum display, and CLI formatting code to use this helper. It also updates remaining numeric String.format(...) calls to pass Locale.US explicitly.
Validation
Locale.GERMANYthat:DecimalFormat("#.0000")produces8,64078.6407Double.valueOf("8.6407")succeeds