diff options
author | Abhishek Koneru <akoneru@redhat.com> | 2012-06-20 13:56:57 -0400 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-06-25 13:38:26 -0500 |
commit | 8a8436f73d4c4edd10b43313b724f32ccb7b957e (patch) | |
tree | 657c8f9accd34d286acf0569f768c72684a12b75 /base/common/src/com/netscape/cmscore/security | |
parent | de3aaef15e9b1f192344019f52d6c80860055b5e (diff) | |
download | pki-8a8436f73d4c4edd10b43313b724f32ccb7b957e.tar.gz pki-8a8436f73d4c4edd10b43313b724f32ccb7b957e.tar.xz pki-8a8436f73d4c4edd10b43313b724f32ccb7b957e.zip |
Fixes for Coverity issues of type Resource Leaks - Remaining
Diffstat (limited to 'base/common/src/com/netscape/cmscore/security')
-rw-r--r-- | base/common/src/com/netscape/cmscore/security/PWsdrCache.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java index 17cc9f0a7..b0445bd6d 100644 --- a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java +++ b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java @@ -325,13 +325,21 @@ public class PWsdrCache { bos.write(readbuf, 0, numRead); totalRead += numRead; } - inputs.close(); + } catch (FileNotFoundException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_SECURITY_PW_FILE", mPWcachedb, e.toString())); throw new EBaseException(e.toString() + ": " + mPWcachedb); } catch (IOException e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_SECURITY_PW_FILE", mPWcachedb, e.toString())); throw new EBaseException(e.toString() + ": " + mPWcachedb); + } finally { + if (inputs != null) { + try { + inputs.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } if (totalRead > 0) { @@ -354,6 +362,7 @@ public class PWsdrCache { * encrypts and writes the whole String buf into pwcache.db */ public void writePWcache(String bufs) throws EBaseException { + FileOutputStream outstream = null; try { Encryptor sdr = new Encryptor(mToken, mKeyID, Encryptor.DEFAULT_ENCRYPTION_ALG); @@ -376,10 +385,10 @@ public class PWsdrCache { tmpPWcache.delete(); tmpPWcache = new File(mPWcachedb + ".tmp"); } - FileOutputStream outstream = new FileOutputStream(mPWcachedb + ".tmp"); + outstream = new FileOutputStream(mPWcachedb + ".tmp"); outstream.write(writebuf); - outstream.close(); + File origFile = new File(mPWcachedb); @@ -427,6 +436,14 @@ public class PWsdrCache { } catch (Exception e) { log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_SECURITY_PW_FILE", mPWcachedb, e.toString())); throw new EBaseException(e.toString() + ": " + mPWcachedb); + } finally { + if (outstream != null) { + try { + outstream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } } |