Issue #2906 added close to BUFR parser

close netcdf file to solve NFS clean issue


Former-commit-id: abb14c67e7 [formerly 5beb3be2e8] [formerly a1e416da97 [formerly 9675e997369e39455aacadcd72d0d8476f6c7ffc]]
Former-commit-id: a1e416da97
Former-commit-id: a2c0ba7f0b
This commit is contained in:
Brian Clements 2014-04-29 12:48:24 -05:00
parent 6966b79246
commit 9f1856a6f0
2 changed files with 22 additions and 2 deletions

View file

@ -58,6 +58,7 @@ import com.raytheon.uf.common.status.UFStatus;
* Mar 26, 2014 2905 bclement fixed types, added scale/offset
* Apr 01, 2014 2905 bclement moved splitter functionality to separate utility
* added scanForStructField()
* Apr 29, 2014 2906 bclement added close()
*
* </pre>
*
@ -827,4 +828,13 @@ public class BufrParser {
return structStack.size();
}
/**
* Release resources associated with BUFR file.
*
* @throws IOException
*/
public void close() throws IOException {
this.ncfile.close();
}
}

View file

@ -44,7 +44,8 @@ import com.raytheon.uf.edex.plugin.bufrobs.category.CategoryKey;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 1, 2014 2906 bclement Initial creation
* Apr 01, 2014 2906 bclement Initial creation
* Apr 29, 2014 2906 bclement close parser when finished
*
* </pre>
*
@ -69,9 +70,10 @@ public class BufrObsProcessor {
*/
public PluginDataObject[] process(File bufrFile)
throws BufrObsDecodeException {
BufrParser parser = null;
PluginDataObject[] rval;
try {
BufrParser parser = new BufrParser(bufrFile);
parser = new BufrParser(bufrFile);
CategoryKey key = getBufrCategory(parser);
AbstractBufrSfcObsDecoder decoder = getDecoder(key);
if (decoder == null) {
@ -86,6 +88,14 @@ public class BufrObsProcessor {
} catch (IOException e) {
throw new BufrObsDecodeException("Unable to read BUFR file: "
+ bufrFile, e);
} finally {
if (parser != null)
try {
parser.close();
} catch (IOException e) {
throw new BufrObsDecodeException(
"Unable to close parser for file: " + bufrFile, e);
}
}
return rval;
}