From 05b0af19e55450073d4bd4639c11a5cbfefaaaeb Mon Sep 17 00:00:00 2001 From: Richard Morales Date: Mon, 10 Dec 2012 13:06:55 -0500 Subject: [PATCH] IDEMPIERE-455 Discover and fix FindBugs problems / Pattern RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE --- .../src/org/compiere/db/CConnection.java | 1 + org.adempiere.base/src/org/compiere/util/DB.java | 3 ++- .../src/org/adempiere/webui/panel/RolePanel.java | 6 +++--- .../src/org/adempiere/webui/window/FindWindow.java | 10 ++++++---- .../src/org/adempiere/webui/window/WEMailDialog.java | 4 ---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/db/CConnection.java b/org.adempiere.base/src/org/compiere/db/CConnection.java index a70c267353..8a452470c9 100644 --- a/org.adempiere.base/src/org/compiere/db/CConnection.java +++ b/org.adempiere.base/src/org/compiere/db/CConnection.java @@ -1276,6 +1276,7 @@ public class CConnection implements Serializable, Cloneable * @param transactionIsolation Connection transaction level * @return Connection */ + @SuppressWarnings("unused") public Connection getConnection (boolean autoCommit, int transactionIsolation) { Connection conn = null; diff --git a/org.adempiere.base/src/org/compiere/util/DB.java b/org.adempiere.base/src/org/compiere/util/DB.java index cde5a93922..26b874d567 100644 --- a/org.adempiere.base/src/org/compiere/util/DB.java +++ b/org.adempiere.base/src/org/compiere/util/DB.java @@ -347,8 +347,9 @@ public final class DB if (conn != null) { conn.close(); + success = true; } - success = (conn != null); + else success = false; } catch (Exception e) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java index fbaf1264b8..0542cd2da7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java @@ -575,9 +575,9 @@ public class RolePanel extends Window implements EventListener, Deferrabl // Elaine 2009/02/06 save preference to AD_Preference UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference(); userPreference.setProperty(UserPreference.P_LANGUAGE, Env.getContext(m_ctx, UserPreference.LANGUAGE_NAME)); - userPreference.setProperty(UserPreference.P_ROLE, lstItemRole != null ? (String) lstItemRole.getValue() : "0"); - userPreference.setProperty(UserPreference.P_CLIENT, lstItemClient != null ? (String) lstItemClient.getValue() : "0"); - userPreference.setProperty(UserPreference.P_ORG, lstItemOrg != null ? (String) lstItemOrg.getValue() : "0"); + userPreference.setProperty(UserPreference.P_ROLE, (String) lstItemRole.getValue()); + userPreference.setProperty(UserPreference.P_CLIENT, (String) lstItemClient.getValue()); + userPreference.setProperty(UserPreference.P_ORG, (String) lstItemOrg.getValue()); userPreference.setProperty(UserPreference.P_WAREHOUSE, lstItemWarehouse != null ? (String) lstItemWarehouse.getValue() : "0"); userPreference.savePreference(); // diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index 091e80c085..3862dfae93 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -1302,11 +1302,13 @@ public class FindWindow extends Window implements EventListener, ValueCha String lBrackets = listLeftBracket.getSelectedItem().getValue().toString(); if ( lBrackets != null ) openBrackets += lBrackets.length(); + else lBrackets = ""; // Right brackets Listbox listRightBracket = (Listbox)row.getFellow("listRightBracket"+row.getId()); String rBrackets = listRightBracket.getSelectedItem().getValue().toString(); if ( rBrackets != null ) openBrackets -= rBrackets.length(); + else rBrackets = ""; // And Or Listbox listAndOr = (Listbox)row.getFellow("listAndOr"+row.getId()); String andOr = listAndOr.getSelectedItem().getValue().toString(); @@ -1341,9 +1343,9 @@ public class FindWindow extends Window implements EventListener, ValueCha .append(FIELD_SEPARATOR) .append(andOr) .append(FIELD_SEPARATOR) - .append(lBrackets != null ? lBrackets : "") + .append(lBrackets) .append(FIELD_SEPARATOR) - .append(rBrackets != null ? rBrackets : ""); + .append(rBrackets); } continue; } @@ -1392,9 +1394,9 @@ public class FindWindow extends Window implements EventListener, ValueCha .append(FIELD_SEPARATOR) .append(andOr) .append(FIELD_SEPARATOR) - .append(lBrackets != null ? lBrackets : "") + .append(lBrackets) .append(FIELD_SEPARATOR) - .append(rBrackets != null ? rBrackets : ""); + .append(rBrackets); } String selected = fQueryName.getValue(); if (selected != null) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java index 4cb601012e..4fee9ee274 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java @@ -516,8 +516,6 @@ public class WEMailDialog extends Window implements EventListener, ValueC if (source.equals(fUser)) { // fUser - if (value == null) - fTo.setText(""); if (value instanceof Integer) { int AD_User_ID = ((Integer)value).intValue(); @@ -526,8 +524,6 @@ public class WEMailDialog extends Window implements EventListener, ValueC } } else { // fCcUser - if (value == null) - fCc.setText(""); if (value instanceof Integer) { int AD_User_ID = ((Integer)value).intValue();