-
Notifications
You must be signed in to change notification settings - Fork 14
Fix NaN incorrectly rejected as invalid value for ASCII_String table fields #1532
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,6 +64,9 @@ public class FieldValueValidator { | |||||||||||||||
| FieldType.IEEE754LSBSINGLE, | ||||||||||||||||
| FieldType.IEEE754MSBDOUBLE, | ||||||||||||||||
| FieldType.IEEE754MSBSINGLE); | ||||||||||||||||
| // String types that accept any string value, including "NaN" (issue #956) | ||||||||||||||||
| private static List<FieldType> stringTypes = Arrays.asList( | ||||||||||||||||
| FieldType.ASCII_STRING); | ||||||||||||||||
|
|
||||||||||||||||
| /** Container to capture messages. */ | ||||||||||||||||
| private ProblemListener listener; | ||||||||||||||||
|
|
@@ -607,7 +610,7 @@ private void checkType(String value, FieldType type) throws InvalidTableExceptio | |||||||||||||||
|
|
||||||||||||||||
| LOG.debug("checkType:value,type:after [{}],[{}]", value, type); | ||||||||||||||||
|
|
||||||||||||||||
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type)) { | ||||||||||||||||
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type) && !stringTypes.contains(type)) { | ||||||||||||||||
|
||||||||||||||||
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type) && !stringTypes.contains(type)) { | |
| // Treat all string field types (including UTF8_STRING) as exempt from the Inf/NaN check. | |
| final boolean isStringType = | |
| stringTypes.contains(type) | |
| || FieldType.UTF8_STRING.getXMLType().equals(type.getXMLType()); | |
| if (SpecialConstantChecker.isInfOrNan(value) && !realTypes.contains(type) && !isStringType) { |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,3 +6,4 @@ Feature: 4.1.x | |||||
| @4.1.x | ||||||
| Examples: | ||||||
| | issueNumber | subtest | datasrc | args | expectation | | ||||||
| | 956 | 1 | "github956" | "--skip-context-validation -t {datasrc}/" | | | ||||||
|
||||||
| | 956 | 1 | "github956" | "--skip-context-validation -t {datasrc}/" | | | |
| | 956 | 1 | "github956" | "--skip-context-validation -t {datasrc}/" | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stringTypesis a mutable, non-final static collection. Since it’s used as a constant for type classification, make itstatic finaland preferably an immutableSet(e.g.,EnumSet) to avoid accidental modification and to make membership checks clearer.