Skip to content

Commit

Permalink
fix: EXPOSED-373 Close ResultSet before closing Statement to suppress…
Browse files Browse the repository at this point in the history
… Agroal leak warning (#2247)

* fix: close ResultSet before closing Statement

suppresses "JDBC resources leaked" warning with agroal

* fix: close ResultSet before closing Statement

address review comments
  • Loading branch information
ivan-gomes authored Sep 23, 2024
1 parent 420fe6f commit 27baa04
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ abstract class AbstractQuery<T : AbstractQuery<T>>(
set(value) {
field = value
if (!field) {
rs.statement?.close()
val statement = rs.statement
rs.close()
statement?.close()
transaction.openResultSetsCount--
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ open class ExplainQuery(
set(value) {
field = value
if (!field) {
rs.statement?.close()
val statement = rs.statement
rs.close()
statement?.close()
transaction.openResultSetsCount--
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ open class InsertStatement<Key : Any>(
return inserted.apply {
insertedCount = this
resultedValues = processResults(rs, this)
rs?.close()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ open class ReturningStatement(
set(value) {
field = value
if (!field) {
rs.statement?.close()
val statement = rs.statement
rs.close()
statement?.close()
transaction.openResultSetsCount--
}
}
Expand Down

0 comments on commit 27baa04

Please sign in to comment.