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.severe(e.getMessage());
} finally {
stmt.close();
if (stmt != null)stmt.close();
if(execOk)
conn.commit();
else

View File

@ -269,7 +269,7 @@ public class DefaultModelFactory implements IModelFactory {
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;
}
catch (Exception e)

View File

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

View File

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

View File

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

View File

@ -103,7 +103,7 @@ public class GridTab2PackExporter implements IGridTabExporter {
}
}
try {
packOut.export(getPackoutDirectory(), file.getAbsolutePath(), packoutDocument, packoutItems, null);
packOut.export(getPackoutDirectory(), file!=null ? file.getAbsolutePath() : null , packoutDocument, packoutItems, null);
} catch (Exception 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());
} finally {
try {
setStatementTimeout(stmt.getConnection(), currentTimeout);
if(stmt!=null)setStatementTimeout(stmt.getConnection(), currentTimeout);
} catch (SQLException e) {}
DB.close(rs, stmt);
}