From 0ac4752b2b811f256a5fd1be148f53f1068332a1 Mon Sep 17 00:00:00 2001 From: Timo Briddigkeit Date: Fri, 15 Jul 2016 09:47:08 +0200 Subject: [PATCH] Fixed null pointer dereference --- .../carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index 1530b8edfc..d622270e92 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -473,8 +473,8 @@ public class PolicyDAOImpl implements PolicyDAO { try { conn = this.getConnection(); String query = "SELECT * FROM DM_POLICY_CHANGE_MGT WHERE TENANT_ID = ?"; - stmt.setInt(1, tenantId); stmt = conn.prepareStatement(query); + stmt.setInt(1, tenantId); resultSet = stmt.executeQuery(); while (resultSet.next()) { @@ -1302,11 +1302,7 @@ public class PolicyDAOImpl implements PolicyDAO { if (log.isDebugEnabled()) { log.debug("Policy (" + policyId + ") delete from database."); } - if (deleted > 0) { - return true; - } else { - return false; - } + return deleted > 0; } catch (SQLException e) { throw new PolicyManagerDAOException("Unable to delete the policy (" + policyId + ") from database", e); } finally { @@ -1584,7 +1580,7 @@ public class PolicyDAOImpl implements PolicyDAO { byte[] contentBytes; try { - contentBytes = (byte[]) resultSet.getBytes("POLICY_CONTENT"); + contentBytes = resultSet.getBytes("POLICY_CONTENT"); bais = new ByteArrayInputStream(contentBytes); ois = new ObjectInputStream(bais); policy = (Policy) ois.readObject();