Skip to content

Commit

Permalink
Slf4JSqlLogger: avoid NPE when used with Script
Browse files Browse the repository at this point in the history
Fixes #1961
  • Loading branch information
stevenschlansker committed Dec 7, 2021
1 parent 127fda1 commit 0017222
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
@@ -1,5 +1,6 @@
# Unreleased
- *SPI change* `@Json String` database type mappers now use `@EncodedJson String` instead (#1953)
- Sql4JSqlLogger: fix NPE when using Script

# 3.24.1
- fix Bean property arguments type being erased on generic beans
Expand Down
Expand Up @@ -15,6 +15,7 @@

import java.sql.SQLException;
import java.time.Duration;
import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -49,7 +50,9 @@ public void logAfterExecution(StatementContext context) {
public void logException(StatementContext context, SQLException ex) {
if (log.isErrorEnabled()) {
log.error("Exception while executing '{}' with parameters '{}'",
context.getParsedSql().getSql(),
Optional.ofNullable(context.getParsedSql())
.map(ParsedSql::getSql)
.orElse("<not available>"),
context.getBinding(),
ex);
}
Expand Down

0 comments on commit 0017222

Please sign in to comment.