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

Fix NPE for Slf4JSqlLogger#logAfterExecution #2000

Merged
merged 1 commit into from Feb 18, 2022

Conversation

tmichel
Copy link
Contributor

@tmichel tmichel commented Feb 17, 2022

The NPE issue (#1961) during logging has already come up but the fix (0017222) only addressed the NPE for logException and not for logAfterExecution.

I extracted getting the SQL string from the StatementContext into a helper method. I opted for not using an Optional and rather use a conditional.

There were no tests for Slf4JSqlLogger so I added some that reproduced the issue. I opted to not write a comprehensive test suite to keep the pull request more focused.

Copy link
Member

@stevenschlansker stevenschlansker left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this!

StatementContext for Batch does not have ParsedSql. Both
logAfterExecution and logException checks whether
StatementContext#getParsedSql returns null or not to avoid an NPE.
@tmichel
Copy link
Contributor Author

tmichel commented Feb 18, 2022

I fixed the unused import error. What else do you need to get this merged?

@stevenschlansker stevenschlansker merged commit 6306a1c into jdbi:master Feb 18, 2022
stevenschlansker added a commit that referenced this pull request Feb 18, 2022
@stevenschlansker
Copy link
Member

Thanks @tmichel , released as 3.27.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants