Issue #2906 added close to BUFR parser

close netcdf file to solve NFS clean issue

(cherry picked from commit 9434b5c653b3a542cc56eac1081f0ab7126966a2 [formerly a1e416da97] [formerly 5beb3be2e8 [formerly 9675e997369e39455aacadcd72d0d8476f6c7ffc]])


Former-commit-id: bb17c8cfc1 [formerly 4599660af98619505fa69a53453218f733eeeea6]
Former-commit-id: 80a0bba04e
This commit is contained in:
Brian Clements 2014-04-29 12:48:24 -05:00 committed by Steve Harris
parent 339ab4258a
commit 5e72d873aa
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;
}