mirror of https://github.com/apache/nifi.git
NIFI-1035 AbstractKiteProcessor.getSchema leaks file handles. closes #101.
Close file handles when reading schema from resources or paths in AbstractKiteProcessor.getSchema Signed-off-by: joewitt <joewitt@apache.org>
This commit is contained in:
parent
22924c656b
commit
943ccfedef
|
@ -121,14 +121,17 @@ abstract class AbstractKiteProcessor extends AbstractProcessor {
|
||||||
if ("dataset".equals(uri.getScheme()) || "view".equals(uri.getScheme())) {
|
if ("dataset".equals(uri.getScheme()) || "view".equals(uri.getScheme())) {
|
||||||
return Datasets.load(uri).getDataset().getDescriptor().getSchema();
|
return Datasets.load(uri).getDataset().getDescriptor().getSchema();
|
||||||
} else if ("resource".equals(uri.getScheme())) {
|
} else if ("resource".equals(uri.getScheme())) {
|
||||||
InputStream in = Resources.getResource(uri.getSchemeSpecificPart())
|
try (InputStream in = Resources.getResource(uri.getSchemeSpecificPart())
|
||||||
.openStream();
|
.openStream()) {
|
||||||
return parseSchema(uri, in);
|
return parseSchema(uri, in);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// try to open the file
|
// try to open the file
|
||||||
Path schemaPath = new Path(uri);
|
Path schemaPath = new Path(uri);
|
||||||
FileSystem fs = schemaPath.getFileSystem(conf);
|
FileSystem fs = schemaPath.getFileSystem(conf);
|
||||||
return parseSchema(uri, fs.open(schemaPath));
|
try (InputStream in = fs.open(schemaPath)) {
|
||||||
|
return parseSchema(uri, in);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (DatasetNotFoundException e) {
|
} catch (DatasetNotFoundException e) {
|
||||||
|
|
Loading…
Reference in New Issue