Skip to content

Commit 8fb137a

Browse files
author
Mansheng Yang
committed
Fixed ByteBuf leaks
PostgreSQLConnection.onDataRow should release the raw ByteBufs after decoding the data
1 parent 773a28d commit 8fb137a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/PostgreSQLConnection.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,16 @@ class PostgreSQLConnection
191191
var x = 0
192192

193193
while ( x < m.values.size ) {
194-
items(x) = if ( m.values(x) == null ) {
194+
val buf = m.values(x)
195+
items(x) = if ( buf == null ) {
195196
null
196197
} else {
197-
val columnType = this.currentQuery.get.columnTypes(x)
198-
this.decoderRegistry.decode(columnType, m.values(x), configuration.charset)
198+
try {
199+
val columnType = this.currentQuery.get.columnTypes(x)
200+
this.decoderRegistry.decode(columnType, buf, configuration.charset)
201+
} finally {
202+
buf.release()
203+
}
199204
}
200205
x += 1
201206
}

0 commit comments

Comments
 (0)