Skip to content

Commit

Permalink
ResultSet & Statement leaks in simple query #871 / Possible fix for n…
Browse files Browse the repository at this point in the history
…ot closed inputStreams.
  • Loading branch information
Tapac committed May 25, 2020
1 parent c74b14a commit 5165254
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ open class BasicBinaryColumnType : ColumnType() {
override fun sqlType(): String = currentDialect.dataTypeProvider.binaryType()

override fun valueFromDB(value: Any): Any = when (value) {
is Blob -> value.binaryStream.readBytes()
is InputStream -> value.readBytes()
is Blob -> value.binaryStream.use { it.readBytes() }
is InputStream -> value.use { it.readBytes() }
else -> value
}

Expand Down Expand Up @@ -542,8 +542,8 @@ class BlobColumnType : ColumnType() {

override fun valueFromDB(value: Any): ExposedBlob = when (value) {
is ExposedBlob -> value
is Blob -> ExposedBlob(value.binaryStream.readBytes())
is InputStream -> ExposedBlob(value.readBytes())
is Blob -> ExposedBlob(value.binaryStream.use { it.readBytes() })
is InputStream -> ExposedBlob(value.use { it.readBytes() })
is ByteArray -> ExposedBlob(value)
else -> error("Unexpected value of type Blob: $value of ${value::class.qualifiedName}")
}
Expand All @@ -562,7 +562,7 @@ class BlobColumnType : ColumnType() {
return if (currentDialect.dataTypeProvider.blobAsStream) {
rs.getBytes(index)?.let(::ExposedBlob)
} else {
rs.getBlob(index)?.binaryStream?.readBytes()?.let(::ExposedBlob)
rs.getBlob(index)?.binaryStream?.use { ExposedBlob(it.readBytes()) }
}
}

Expand Down

0 comments on commit 5165254

Please sign in to comment.