pjfanning opened a new pull request, #607: URL: https://github.com/apache/pekko-persistence-jdbc/pull/607
### Motivation The Oracle snapshot column mapping converts a blob with `blob.getBinaryStream.toArray`: ```scala MappedColumnType.base[Array[Byte], Blob](bytes => new SerialBlob(bytes), blob => blob.getBinaryStream.toArray) ``` `InputStreamOps.toArray` reads the stream to the end but never closes it, and neither does the call site, so every snapshot that is read from Oracle leaves a stream open. That stream is backed by driver resources (a cursor or a temporary lob) which are only released when the connection is returned or the garbage collector runs. The same code exists in the current and the legacy snapshot tables. ### Modification Added `BlobOps.toArray` (internal API), which reads the blob and closes the stream in a `finally` block, and used it in both `snapshot/dao/SnapshotTables.scala` and `snapshot/dao/legacy/SnapshotTables.scala`. ### Result Reading snapshots from Oracle no longer leaks a stream per row. ### Tests - `sbt "core/testOnly org.apache.pekko.persistence.jdbc.util.BlobOpsSpec"` - passed. The new spec asserts that the stream is closed both after a successful read and when reading throws. - `sbt "core/testOnly *H2*Snapshot*"` - passed - `sbt "core/mimaReportBinaryIssues"` - passed - `scalafmt --mode diff-ref=upstream/main` - no changes Not tested against Oracle - no Oracle instance available here; the changed conversion is exercised only by the Oracle profile. ### References None - found while reviewing the main sources for resource leaks -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
