Skip to content
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

[#1695] Fix parsing of 'tru...' values inconsistent to true boolean #1741

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

laurentschoelens
Copy link
Contributor

Fixes #1695
Adding test case to validate _parseBoolean function

@antoniosanct
Copy link
Contributor

Hi, @laurentschoelens:

I have some questions about this PR because it could be some mistakes based on another tests at the same project:

  • Are using JUnit 4 for any reason? You can extend JUnit 3's TestCase superclass by same manner than other tests that exists at the same project.
  • You didn't fix the 'f' case clause. For this reason, unit tests in your own test file, lines 25, 34, 35, 36 and 41, expects null while the correct value would be false, according to use the same solution for 't' case clause.

Regards,
Antonio.

@laurentschoelens
Copy link
Contributor Author

Hi @antoniosanct

Hi, @laurentschoelens:

I have some questions about this PR because it could be some mistakes based on another tests at the same project:

  • Are using JUnit 4 for any reason? You can extend JUnit 3's TestCase superclass by same manner than other tests that exists at the same project.

Is there any reason to stay to JUnit 3 testing style ? Since JUnit 5 is out for a moment, I would say that the best option would be to start migration to JUnit 5.
I can sure adapt to JUnit 3.

  • You didn't fix the 'f' case clause. For this reason, unit tests in your own test file, lines 25, 34, 35, 36 and 41, expects null while the correct value would be false, according to use the same solution for 't' case clause.

You're right. Since this class is deprecated and behaviour inconsistent, I didnt want to change too much.
Will fix more parseBoolean inconsistent results based on the same PR I did in API with more strict boolean checking : jakartaee/jaxb-api#279

Regards,
Antonio.

Regards,
Laurent

@antoniosanct
Copy link
Contributor

@laurentschoelens
I'm agree with you about JUnit 5. My point is to use other PR to improve it.

@laurentschoelens
Copy link
Contributor Author

@laurentschoelens
I'm agree with you about JUnit 5. My point is to use other PR to improve it.

Ok but I didnt add junit4 dependency, it was already in the classpath, no ?

@lukasj
Copy link
Member

lukasj commented Sep 13, 2023

as long as the test runs as part of the build, it does not matter whether it is 3 or 4; 4 is on the classpath already

@laurentschoelens
Copy link
Contributor Author

Let me fix my PR first before merging this one @lukasj

@laurentschoelens
Copy link
Contributor Author

@antoniosanct new commit to be more accurate based on API impl (without throwing any excepion)

…ue boolean

impl now has same results as api but returning null
instead of exception according to jakartaee/jaxb-api#240
@antoniosanct
Copy link
Contributor

antoniosanct commented Sep 18, 2023

Hi, @laurentschoelens
Is it correct to return instead of when it parses other string than "1" or "true"?
Regards,
Antonio!

@laurentschoelens
Copy link
Contributor Author

@antoniosanct missing comment no ? 😄

@antoniosanct
Copy link
Contributor

antoniosanct commented Sep 18, 2023

@laurentschoelens
Sorry, I wanted to say "1" or "true". Whatever, what's the best result when it parses other value than "1" or "true"?
https://www.w3.org/TR/xmlschema-2/#boolean
Thanks again!
Antonio

@laurentschoelens
Copy link
Contributor Author

In my opinion and in author original spirit, when it parses 0 or false, it should return false, when something else, since not a boolean in xsd representation, that will be null or Exception (in api).
I've just aligned the impl code in jaxb-ri to the same code in api with that difference (null in ri vs exception in api)

@antoniosanct
Copy link
Contributor

@laurentschoelens
OK for me! Thanks a lot for this PR!!

Copy link
Member

@lukasj lukasj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lukasj lukasj merged commit 36eb718 into eclipse-ee4j:master Oct 6, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatatypeConverter.parseBoolean converts invalid strings to true
3 participants