IDEMPIERE-455 Discover and fix FindBugs problems / Pattern NP_NULL_ON_SOME_PATH_EXCEPTION

This commit is contained in:
Richard Morales 2012-12-12 10:49:56 -05:00
parent efe1098479
commit 4c16922d20
7 changed files with 29 additions and 21 deletions

View File

@ -156,7 +156,7 @@ public class ApplyMigrationScripts extends SvrProcess {
log.saveError("Error", msglog.toString()); log.saveError("Error", msglog.toString());
log.severe(e.getMessage()); log.severe(e.getMessage());
} finally { } finally {
stmt.close(); if (stmt != null)stmt.close();
if(execOk) if(execOk)
conn.commit(); conn.commit();
else else

View File

@ -269,7 +269,7 @@ public class DefaultModelFactory implements IModelFactory {
s_log.warning("No transaction Constructor for " + clazz + " (" + msg + ")"); s_log.warning("No transaction Constructor for " + clazz + " (" + msg + ")");
} }
PO po = (PO)constructor.newInstance(new Object[] {Env.getCtx(), new Integer(Record_ID), trxName}); PO po = constructor!=null ? (PO)constructor.newInstance(new Object[] {Env.getCtx(), new Integer(Record_ID), trxName}) : null;
return po; return po;
} }
catch (Exception e) catch (Exception e)

View File

@ -639,11 +639,14 @@ public class PrintData implements Serializable
e.printStackTrace(); e.printStackTrace();
} }
// Root // Root
Element root = document.createElement(PrintData.XML_TAG); if (document != null) {
root.setAttribute(XML_ATTRIBUTE_NAME, getName()); Element root = document.createElement(PrintData.XML_TAG);
root.setAttribute(XML_ATTRIBUTE_COUNT, String.valueOf(getRowCount())); root.setAttribute(XML_ATTRIBUTE_NAME, getName());
document.appendChild(root); root.setAttribute(XML_ATTRIBUTE_COUNT, String.valueOf(getRowCount()));
processXML (this, document, root); document.appendChild(root);
processXML (this, document, root);
}
return document; return document;
} // getDocument } // getDocument

View File

@ -329,9 +329,11 @@ public final class Ini implements Serializable
try try
{ {
InputStream is = fc.getInputStream(); if (fc != null) {
s_prop.load(is); InputStream is = fc.getInputStream();
is.close(); s_prop.load(is);
is.close();
}
} }
catch (Throwable t) catch (Throwable t)
{ {

View File

@ -352,16 +352,19 @@ public class Secure implements SecureInterface
nsae.printStackTrace(); nsae.printStackTrace();
} }
} }
// Reset MessageDigest object // Convert String to array of bytes
m_md.reset();
// Convert String to array of bytes
byte[] input = value.getBytes(); byte[] input = value.getBytes();
// feed this array of bytes to the MessageDigest object byte[] output = null;
m_md.update(input); // Reset MessageDigest object
// Get the resulting bytes after the encryption process if (m_md != null) {
byte[] output = m_md.digest(); m_md.reset();
m_md.reset(); // feed this array of bytes to the MessageDigest object
// m_md.update(input);
// Get the resulting bytes after the encryption process
output = m_md.digest();
m_md.reset();
//
}
return convertToHexString(output); return convertToHexString(output);
} // getDigest } // getDigest

View File

@ -103,7 +103,7 @@ public class GridTab2PackExporter implements IGridTabExporter {
} }
} }
try { try {
packOut.export(getPackoutDirectory(), file.getAbsolutePath(), packoutDocument, packoutItems, null); packOut.export(getPackoutDirectory(), file!=null ? file.getAbsolutePath() : null , packoutDocument, packoutItems, null);
} catch (Exception e) { } catch (Exception e) {
throw new AdempiereException(e); throw new AdempiereException(e);
} }

View File

@ -1032,7 +1032,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
throw new DBException("Could not lock record for " + po.toString() + " caused by " + e.getLocalizedMessage()); throw new DBException("Could not lock record for " + po.toString() + " caused by " + e.getLocalizedMessage());
} finally { } finally {
try { try {
setStatementTimeout(stmt.getConnection(), currentTimeout); if(stmt!=null)setStatementTimeout(stmt.getConnection(), currentTimeout);
} catch (SQLException e) {} } catch (SQLException e) {}
DB.close(rs, stmt); DB.close(rs, stmt);
} }