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

Conditional check for data-source-ref is incorrect #14742

Closed

Conversation

sheriumair
Copy link
Contributor

This PR removes a redundant conditional check in the doParse method of the specified class. The condition dataSource != null is always evaluated as true because the getAttribute method always returns a value. By removing this redundant check, the code becomes more concise and easier to read while maintaining the error handling logic when necessary. This change aligns with best practices for code simplification and improves code quality.

@pivotal-cla
Copy link

@sheriumair Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 13, 2024
@pivotal-cla
Copy link

@sheriumair Thank you for signing the Contributor License Agreement!

@sjohnr sjohnr added in: config An issue in spring-security-config type: bug A general bug labels Mar 14, 2024
@sjohnr sjohnr self-assigned this Mar 14, 2024
@sjohnr
Copy link
Member

sjohnr commented Mar 14, 2024

@sheriumair thanks for the PR!

It's possible the original code was incorrect (this code goes back to 2007), but the null check appears to have been intended to handle the situation where the data-source-ref attribute is missing.

while maintaining the error handling logic when necessary.

I'm not sure the fix is correct. Can you please update the PR to correctly fix the issue and add a test asserting the behavior you are fixing (e.g. an XML with missing data-source-ref)?

@sjohnr sjohnr added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 14, 2024
@sheriumair
Copy link
Contributor Author

Hey @sjohnr ! Thanks for pointing out this issue in my PR. dataSource variable can be empty but not null. So if it is empty then we have to handle that case. I will correct this issue in my upcoming PR and write a test where data-source-ref is missing.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 15, 2024
@sheriumair
Copy link
Contributor Author

Hey @sjohnr! Can you kindly review the PR, please?

Copy link
Member

@sjohnr sjohnr left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @sheriumair. Please see my comments below.

@sheriumair
Copy link
Contributor Author

Hey @sjohnr. Thank you for your review. I have changed to hasText and added another test when data-source-ref attribute is entirely missing.

@sheriumair sheriumair requested a review from sjohnr March 25, 2024 19:15
@sheriumair
Copy link
Contributor Author

sheriumair commented Mar 26, 2024

Hey @sjohnr ! Apologies for the oversight, I committed the code without running the Checkstyle analysis. I have now corrected the code to adhere to the coding standards and have ensured that it passes the Checkstyle checks. Please review the updated PR. Thank you for your understanding.

Copy link
Member

@sjohnr sjohnr left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @sheriumair! Please see additional comments below.

@sjohnr
Copy link
Member

sjohnr commented Mar 26, 2024

Once you are finished with the above updates, would you mind please squashing your commits?

@sheriumair sheriumair force-pushed the fix/datasource-validation branch 3 times, most recently from c45d309 to e084eef Compare March 27, 2024 18:20
@sheriumair sheriumair requested a review from sjohnr March 27, 2024 18:22
@sheriumair
Copy link
Contributor Author

Hey @sjohnr! I have squashed my commits and changed the XML to multi line

@sjohnr
Copy link
Member

sjohnr commented Mar 27, 2024

Hi @sheriumair! Looks like there's still two commits? I think there should only be one.

Fixed data source validation
@sheriumair
Copy link
Contributor Author

Hey @sjohnr . I hope my latest PR solves all the issues.

@sheriumair
Copy link
Contributor Author

Hey @sjohnr! Is there anything else that is left on my side?

@sjohnr
Copy link
Member

sjohnr commented Apr 3, 2024

@sheriumair I don't believe so. I will work on getting this merged tomorrow. If anything is remaining I will apply a polish commit. Thanks for your contribution!

sjohnr added a commit that referenced this pull request Apr 4, 2024
@sjohnr
Copy link
Member

sjohnr commented Apr 4, 2024

Thanks @sheriumair! This has now been merged as 33ebd54 with polish commit 39dbd24.

@sjohnr sjohnr closed this Apr 4, 2024
@sjohnr sjohnr added this to the 5.8.12 milestone Apr 4, 2024
@sjohnr sjohnr removed the status: feedback-provided Feedback has been provided label Apr 4, 2024
@sjohnr sjohnr changed the title Fix/datasource validation Conditional check for data-source-ref is incorrect Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config type: bug A general bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants