NumberFormatException as Persistent Data Value not processing double value properly #45

Closed
htt opened this Issue Aug 29, 2012 · 5 comments

Projects

None yet

4 participants

@htt

(Platform #228)

  • Create/select an example component.
  • Open Inspector > Model Persistence view. Set Description=abc, Value=11.11, click Save. Commit the change.
  • Switch to Info view: "abc" and "11.11" propagated properly. From here, change 11.11 to 1100.1234567890. Commit.
  • In Model Persistence view, notice that Value is truncated to 1,100.123. From here, change Value to 1100.1234567890, click Save. Observe:

Issue #1 -- NumberFormatException thrown (*)
Issue #2 -- the error dialog shows an ambiguous message taht starts with "For input string: "1,100.123""
Issue #3 -- click OK to dismiss the error dialog. Click in the Value and Description fields: notice only Value is editable at this point.

@custardtart custardtart was assigned Aug 29, 2012
@harleigh harleigh was assigned Aug 2, 2013
@VWoeltjen
NASA member

See #136 for screen shot

@harleigh

After a quick peek into the code, I see that, upon entering "999999949.82" into the 'Value' text-field, we have in the save button, the text-field has the value of "999,999,949.82". The code tries to parse this text-field (with all of the commas) as a double: hence NumberFormatException.

code-area: SaveModelStateView.java in the exampleplugin project.

Quick fixes:
*remove the code that inserts commas into the number
*regex to punch out the commas
*the first-solution here http://stackoverflow.com/questions/11973383/how-to-parse-number-string-containing-commas-into-an-integer-in-java

@harleigh

Upon further inspection, the input to the 'Value' text field was being injected with commas by Java's NumberFormat

@VWoeltjen
NASA member

Verified in Hackathon 9/25/2013 (Mac OS X & Windows 7)

@VWoeltjen VWoeltjen closed this Sep 25, 2013
@harleigh

Verified in Hackathon 9/25/2013 (Linux on otf2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment