-
Notifications
You must be signed in to change notification settings - Fork 241
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
ND2 defensive parsing #691
Conversation
|
--test nd2 |
|
Excluding, as this caused http://hudson.openmicroscopy.org.uk/view/Bio-Formats/job/BIOFORMATS-full-repository-stable/335/ to fail. Most likely, wrapping all of the metadata parsing in a single try/catch block prevents something from executing, but what exactly is not obvious from the diff. For a more manageable example to test locally, this should result in 11 test failures with this PR's branch:
The same test with dev_4_4 alone results in 0 failures. |
Several numerical parsing methods throw NumberFormatException when the input string is not actually a number. In particular: * Integer.parseInt(String) * Double.parseDouble(String) * new Integer(String) * new Double(String) The ND2 handler parses a large number of string key/value pairs, converting values into numbers in many cases. But in almost every case, no error handling was done in case the input value was not a number. This change adds a blanket try/catch for NumberFormatException around areas that parse lots of numbers, emitting a warning for any non-conforming key/value pairs. This allows parsing to continue, hopefully resulting in a less fragile ND2 reader. It also catches NumberFormatException separately within the nested TextInfoItem parse loop, so that parsing of TextInfoItem entries fail individually rather than all-or-nothing. Note that this change is nearly all whitespace indentation; the easiest way to view the "real" change is using "git show -b" on the commit.
|
Thanks @melissalinkert. The problem was that the All the tests now pass on my system for |
|
|
|
Builds as of today looked good, @ctrueden. @melissalinkert ? |
|
Thanks @joshmoore. 😂 |
|
--rebased-to #700 |
This change is an attempted fix for Fiji bug #655.
Several numerical parsing methods throw
NumberFormatExceptionwhen the input string is not actually a number. In particular:Integer.parseInt(String)Double.parseDouble(String)new Integer(String)new Double(String)The ND2 handler parses a large number of string key/value pairs, converting values into numbers in many cases. But in almost every case, no error handling was done in case the input value was not a number.
This change adds a blanket try/catch for
NumberFormatExceptionaround areas that parse lots of numbers, emitting a warning for any non-conforming key/value pairs. This allows parsing to continue, hopefully resulting in a less fragile ND2 reader.Note that this change is nearly all whitespace indentation; the easiest way to view the "real" change is using
git show -bon the commit.