mirror of https://github.com/apache/nifi.git
NIFI-7167 This closes #4486. Fixing resource leaks in IdentifyMimeType
The TikaInputStream and FileInputStream instances utilized in IdentifyMimeType are now explicitly closed. The FileInputStream is additionally wrapped by a BufferedInputStream. Signed-off-by: Joe Witt <joewitt@apache.org>
This commit is contained in:
parent
c3cab48325
commit
9a1ae469d8
|
@ -177,8 +177,9 @@ public class IdentifyMimeType extends AbstractProcessor {
|
|||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
this.detector = MimeTypesFactory.create(new FileInputStream(configFile));
|
||||
try (final FileInputStream fis = new FileInputStream(configFile);
|
||||
final InputStream bis = new BufferedInputStream(fis)) {
|
||||
this.detector = MimeTypesFactory.create(bis);
|
||||
this.mimeTypes = (MimeTypes)this.detector;
|
||||
} catch (Exception e) {
|
||||
context.yield();
|
||||
|
@ -212,8 +213,8 @@ public class IdentifyMimeType extends AbstractProcessor {
|
|||
session.read(flowFile, new InputStreamCallback() {
|
||||
@Override
|
||||
public void process(final InputStream stream) throws IOException {
|
||||
try (final InputStream in = new BufferedInputStream(stream)) {
|
||||
TikaInputStream tikaStream = TikaInputStream.get(in);
|
||||
try (final InputStream in = new BufferedInputStream(stream);
|
||||
final TikaInputStream tikaStream = TikaInputStream.get(in)) {
|
||||
Metadata metadata = new Metadata();
|
||||
|
||||
if (filename != null && context.getProperty(USE_FILENAME_IN_DETECTION).asBoolean()) {
|
||||
|
|
Loading…
Reference in New Issue