From 3c8a573a48f660484e8a414d8d80324273412baa Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Tue, 29 Apr 2014 12:48:24 -0500 Subject: [PATCH] Issue #2906 added close to BUFR parser close netcdf file to solve NFS clean issue Former-commit-id: abb14c67e7b3bc9c04b21477319aaa5aa8b2798a [formerly 5beb3be2e8d2275c20af59137ea0ea8784ddd60b] [formerly abb14c67e7b3bc9c04b21477319aaa5aa8b2798a [formerly 5beb3be2e8d2275c20af59137ea0ea8784ddd60b] [formerly a1e416da978e0de3f7a1d9f4679f11eab2f7270b [formerly 9675e997369e39455aacadcd72d0d8476f6c7ffc]]] Former-commit-id: a1e416da978e0de3f7a1d9f4679f11eab2f7270b Former-commit-id: 9f1856a6f0771a5408a2a74ec5104e187c70d689 [formerly a2c0ba7f0ba68f51fa3176ba5129d10505acf2fa] Former-commit-id: f03c6cdcf96c7704d9192220fee4d68a24121389 --- .../com/raytheon/uf/common/nc/bufr/BufrParser.java | 10 ++++++++++ .../uf/edex/plugin/bufrobs/BufrObsProcessor.java | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.nc.bufr/src/com/raytheon/uf/common/nc/bufr/BufrParser.java b/edexOsgi/com.raytheon.uf.common.nc.bufr/src/com/raytheon/uf/common/nc/bufr/BufrParser.java index d717ac9031..1d115c6168 100644 --- a/edexOsgi/com.raytheon.uf.common.nc.bufr/src/com/raytheon/uf/common/nc/bufr/BufrParser.java +++ b/edexOsgi/com.raytheon.uf.common.nc.bufr/src/com/raytheon/uf/common/nc/bufr/BufrParser.java @@ -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() * * * @@ -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(); + } + } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/src/com/raytheon/uf/edex/plugin/bufrobs/BufrObsProcessor.java b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/src/com/raytheon/uf/edex/plugin/bufrobs/BufrObsProcessor.java index 9cf61cd242..46017bc3f3 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/src/com/raytheon/uf/edex/plugin/bufrobs/BufrObsProcessor.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/src/com/raytheon/uf/edex/plugin/bufrobs/BufrObsProcessor.java @@ -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 * * * @@ -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; }