From f68c7133cfac0752d96fa130223f92d5bc0b1690 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 29 May 2015 19:56:29 +0530 Subject: [PATCH] Check null before close connection --- .../mgt/dao/OperationManagementDAOFactory.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java index 117420ca87a..ee6b7357001 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java @@ -94,12 +94,14 @@ public class OperationManagementDAOFactory { public static void closeConnection() throws OperationManagementDAOException { Connection con = currentConnection.get(); - try { - con.close(); - } catch (SQLException e) { - log.error("Error occurred while close the connection"); + if (con != null) { + try { + con.close(); + } catch (SQLException e) { + log.error("Error occurred while close the connection"); + } + currentConnection.remove(); } - currentConnection.remove(); } public static void commitTransaction() throws OperationManagementDAOException {