From 8e9d74c7f69316b53d44e85a175d38df5a8960ba Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 1 Nov 2010 14:32:56 -0700 Subject: [PATCH] bug 5190: This covers the case of unforseen exceptions (although a corner case), which might pop up. We introduce a finally block which will release the cert db record for other ms to process, in case the owning ms errors out (not crash), whilst running the cert update process --- .../src/com/cloud/server/ManagementServerImpl.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index fe5ea38e8b8..34456af8b1f 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -6004,6 +6004,14 @@ public class ManagementServerImpl implements ManagementServer { s_logger.error(msg); throw new ServerApiException(BaseCmd.CUSTOM_CERT_UPDATE_ERROR, msg); } + }finally{ + try { + releaseCertRecord(_certDao.listAll().get(0));//release record in case of unforseen exceptions + } catch (ResourceUnavailableException e) { + String msg = "Unable to release the cert record for other mgmt servers"; + s_logger.error(msg); + throw new ServerApiException(BaseCmd.CUSTOM_CERT_UPDATE_ERROR, msg); + } } return null; } @@ -6013,12 +6021,15 @@ public class ManagementServerImpl implements ManagementServer { if(lockedCert == null){ String msg = "Unable to obtain lock on the cert from releaseCertRecord() in uploadCertificate()"; s_logger.error(msg); + throw new ResourceUnavailableException(msg); }else{ try{ lockedCert.setMgmtServerId(null);//release for other ms _certDao.update(lockedCert.getId(), lockedCert); }catch (Exception e){ - s_logger.warn("Unable to update record in cert table from releaseCertRecord() during uploadCertificate()",e); + String msg = "Unable to update record in cert table from releaseCertRecord() during uploadCertificate()"; + s_logger.warn(msg,e); + throw new ResourceUnavailableException(msg); }finally{ _certDao.release(cert.getId()); }