-
Notifications
You must be signed in to change notification settings - Fork 251
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
KNOX-2995 - Support json parsing NaN values #828
Conversation
you can see this issuse: KNOX-2995 |
@upczsh - could you please be more verbose on the PR description above? |
} | ||
|
||
private void jsonParserConfigInit() { | ||
parser.enable(com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS); |
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.
Why don't you add this feature when creating the factory
in line 69?
Moreover, the referenced feature has been deprecated since 2.10 according to Jackson docs (we use 2.11.4 in Knox already):
/**
* Feature that allows parser to recognize set of
* "Not-a-Number" (NaN) tokens as legal floating number
* values (similar to how many other data formats and
* programming language source code allows it).
* Specific subset contains values that
* <a href="http://www.w3.org/TR/xmlschema-2/">XML Schema</a>
* (see section 3.2.4.1, Lexical Representation)
* allows (tokens are quoted contents, not including quotes):
*<ul>
* <li>"INF" (for positive infinity), as well as alias of "Infinity"
* <li>"-INF" (for negative infinity), alias "-Infinity"
* <li>"NaN" (for other not-a-numbers, like result of division by zero)
*</ul>
*<p>
* Since JSON specification does not allow use of such values,
* this is a non-standard feature, and as such disabled by default.
*
* @deprecated Since 2.10 use {@link com.fasterxml.jackson.core.json.JsonReadFeature#ALLOW_NON_NUMERIC_NUMBERS} instead
*/
@Deprecated
ALLOW_NON_NUMERIC_NUMBERS(false),
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.
@smolnar82 Thanks for your guidance, I have used JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS instead of the deprecated JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS.
On the other hand, the reason for not adding it on line 69 is that this setting is the content of parse, and other json parse configurations may be enabled in the future, so I wrote a separate method.
…the deprecated JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS
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.
LGTM
@upczsh - could you please be more verbose on the PR description above? |
@upczsh - We are about to release Knox v2.1.0 and I'd like to include your change. |
terribly sorry!!! I have updated the PR description.It's my honor to contribute! |
What changes were proposed in this pull request?
Implemented the changes I listed in KNOX-2995:
I click on the page with return json and the content of Resopnse is empty. like this :
Checking the gateway.log log shows the following error message.
![image](https://private-user-images.githubusercontent.com/50791733/309690094-9badb503-6841-445a-8b82-4e62f1a3e819.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNzY2NDUsIm5iZiI6MTczOTI3NjM0NSwicGF0aCI6Ii81MDc5MTczMy8zMDk2OTAwOTQtOWJhZGI1MDMtNjg0MS00NDVhLThiODItNGU2MmYxYTNlODE5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDEyMTkwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZiOTQ5OGRiMWI3MDA3YjViODgyOWMwOWY5YTdhNmUyOGQyNWQ2MGQzNmJhMzc2MWIwYzE1NTQzODZmNmQwZDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.x-5AF2OeRYIODGcEHEc_5T8o0EbNrS5b9CoExQSlWPI)
The display results after my repair are as follows:
![image](https://private-user-images.githubusercontent.com/50791733/309690738-baa5d35d-a643-49b9-b55a-41482f453f5c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNzY2NDUsIm5iZiI6MTczOTI3NjM0NSwicGF0aCI6Ii81MDc5MTczMy8zMDk2OTA3MzgtYmFhNWQzNWQtYTY0My00OWI5LWI1NWEtNDE0ODJmNDUzZjVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDEyMTkwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJkYzM1MzM0ZjEyM2Y0MGFlMzVjMGI4NWJiYTJjMTIwMmRmYjc3NjAwYTg3NWRhYjVhMTkyZWYxZjhhZjIwODQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.jUenWWRl5SdttXsl01Qk2LBFoMYPNrD1hq5ONS6sJpo)
How was this patch tested?
I have added test cases. You can run the test cases to see if they are successful.
Run JsonFilterReaderTest.testNaN() function.
Or look at the actual problems I encountered above to test.