NIFI-8119: properly free database resources when done with the processing of BLOBs

Signed-off-by: Matthew Burgess <mattyb149@apache.org>

This closes #4791
This commit is contained in:
Christian Gumpert 2021-01-30 14:40:37 +01:00 committed by Matthew Burgess
parent d049bca794
commit f2555f27f1
No known key found for this signature in database
GPG Key ID: 05D3DEB8126DAD24
1 changed files with 7 additions and 6 deletions

View File

@ -287,12 +287,13 @@ public class JdbcCommon {
if (blob != null) {
long numChars = blob.length();
byte[] buffer = new byte[(int) numChars];
InputStream is = blob.getBinaryStream();
int index = 0;
int c = is.read();
while (c >= 0) {
buffer[index++] = (byte) c;
c = is.read();
try (InputStream is = blob.getBinaryStream()) {
int index = 0;
int c = is.read();
while (c >= 0) {
buffer[index++] = (byte) c;
c = is.read();
}
}
ByteBuffer bb = ByteBuffer.wrap(buffer);
rec.put(i - 1, bb);