>From b24551b90afec7b2258f6f45a112c1c3328493b9 Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru@redhat.com>
Date: Mon, 2 Jul 2012 11:07:06 -0400
Subject: [PATCH] Fixes for Patch 19's review comments

---
 .../src/com/netscape/ca/CertificateAuthority.java  |    4 +-
 .../cms/publish/publishers/FileBasedPublisher.java |   44 +++++++++++---------
 2 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/base/ca/src/com/netscape/ca/CertificateAuthority.java b/base/ca/src/com/netscape/ca/CertificateAuthority.java
index 962378ce195afdeb8f86a261e0346fb5ec6a9386..f66192cf566144ed1db43bccd579c4e3d3ac787e 100644
--- a/base/ca/src/com/netscape/ca/CertificateAuthority.java
+++ b/base/ca/src/com/netscape/ca/CertificateAuthority.java
@@ -1896,7 +1896,7 @@ public class CertificateAuthority implements ICertificateAuthority, ICertAuthori
             return response;
         } catch (Exception e) {
             log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_OCSP_REQUEST", e.toString()));
-            throw new EBaseException(CMS.getLogMessage("CMSCORE_CA_CA_OCSP_REQUEST"));
+            throw new EBaseException(e.toString());
         }
     }
 
@@ -1940,7 +1940,7 @@ public class CertificateAuthority implements ICertificateAuthority, ICertAuthori
             e.printStackTrace();
             // error e
             log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_OCSP_SIGN", e.toString()));
-            throw new EBaseException(CMS.getLogMessage("CMSCORE_CA_CA_OCSP_SIGN", e.toString()));
+            throw new EBaseException(e.toString());
         }
     }
 
diff --git a/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java b/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
index 535cab26d596d991457f914b43c4087143ba3545..bde3920ce51969b8f3659603e7612acf8a2b857c 100644
--- a/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
+++ b/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
@@ -296,10 +296,14 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
                         File.separator + "cert-" +
                         sno.toString();
                 if (mDerAttr) {
-                    String fileName = name + ".der";
-                    fos = new FileOutputStream(fileName);
-                    fos.write(cert.getEncoded());
-                    fos.close();
+                    try {
+                        String fileName = name + ".der";
+                        fos = new FileOutputStream(fileName);
+                        fos.write(cert.getEncoded());
+                    } finally {
+                        if (fos != null)
+                            fos.close();
+                    }
                 }
                 if (mB64Attr) {
                     String fileName = name + ".b64";
@@ -320,6 +324,8 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
                         if (b64 != null) {
                             b64.close();
                         }
+                        if (fos != null)
+                            fos.close();
                     }
                 }
             } else if (object instanceof X509CRL) {
@@ -334,10 +340,14 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
                 File renameFile = null;
 
                 if (mDerAttr) {
-                    fos = new FileOutputStream(tempFile);
-                    encodedArray = crl.getEncoded();
-                    fos.write(encodedArray);
-                    fos.close();
+                    try {
+                        fos = new FileOutputStream(tempFile);
+                        encodedArray = crl.getEncoded();
+                        fos.write(encodedArray);
+                    } finally {
+                        if (fos != null)
+                            fos.close();
+                    }
                     if (mZipCRL) {
                         try {
                             zos = new ZipOutputStream(new FileOutputStream(baseName + ".zip"));
@@ -378,9 +388,13 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
                 if (mB64Attr == true) {
                     if (encodedArray == null)
                         encodedArray = crl.getEncoded();
-
-                    fos = new FileOutputStream(tempFile);
-                    fos.write(Utils.base64encode(encodedArray).getBytes());
+                    try {
+                        fos = new FileOutputStream(tempFile);
+                        fos.write(Utils.base64encode(encodedArray).getBytes());
+                    } finally {
+                        if (fos != null)
+                            fos.close();
+                    }
                     destName = baseName + ".b64";
                     destFile = new File(destName);
 
@@ -399,14 +413,6 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
         } catch (CRLException e) {
             mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
                     ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_FILE_PUBLISHER_ERROR", e.toString()));
-        } finally {
-            if (fos != null) {
-                try {
-                    fos.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
         }
     }
 
-- 
1.7.10.2

