IDEMPIERE-455 Discover and fix FindBugs problems / Eclipse warning -> dead code

This commit is contained in:
Carlos Ruiz 2012-12-20 15:46:40 -05:00
parent c39047eb17
commit 740908e0c5
23 changed files with 138 additions and 116 deletions

View File

@ -559,8 +559,6 @@ public class ReplicationLocal extends SvrProcess
//
ResultSet rs = pstmt.executeQuery();
rowSet = CCachedRowSet.getRowSet(rs);
pstmt.close();
pstmt = null;
}
catch (Exception ex)
{
@ -568,16 +566,11 @@ public class ReplicationLocal extends SvrProcess
throw new RuntimeException (ex);
}
// Close Cursor
try
finally
{
if (pstmt != null)
pstmt.close();
DB.close(pstmt);
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "close pstmt", e);
}
return rowSet;
} // getRowSet

View File

@ -59,12 +59,12 @@ class Base
GridWindow w = new GridWindow(vo);
long endDef = System.currentTimeMillis();
System.out.println("Load Definition Time in ms = " + String.valueOf(endDef-startTime));
if (1==2) // optional step
/*if (1==2) // optional step
{
w.loadCompete();
long endDefComplete = System.currentTimeMillis();
System.out.println("Load Definition Complete Time in ms = " + String.valueOf(endDefComplete-startTime));
}
}*/
w.query();
long endData = System.currentTimeMillis();
System.out.println("Load Data Time in ms = " + String.valueOf(endData-startTime));

View File

@ -69,8 +69,8 @@ public class LDAP
Attributes answer = ctx.getAttributes("");
// Print the answer
if (false)
dump (answer);
//if (false)
// dump (answer);
}
catch (AuthenticationException e)
{

View File

@ -61,10 +61,10 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im
{
return result;
}
if (m_stream == null)
{
return result;
}
//if (m_stream == null)
//{
//return result;
//}
result = attachInput(m_stream);
}
catch(Exception e)

View File

@ -129,8 +129,8 @@ public class MEXPFormat extends X_EXP_Format {
{
String key = new String(value+version);
MEXPFormat retValue=null;
if(retValue!=null)
return retValue;
//if(retValue!=null)
// return retValue;
StringBuilder whereClause = new StringBuilder(X_EXP_Format.COLUMNNAME_Value).append("=?")
.append(" AND AD_Client_ID = ?")

View File

@ -416,9 +416,9 @@ public class MIssue extends X_AD_Issue
*/
public String report()
{
if (true)
//if (true)
return "-";
StringBuilder parameter = new StringBuilder("?");
/*StringBuilder parameter = new StringBuilder("?");
if (getRecord_ID() == 0) // don't report
return "ID=0";
if (getRecord_ID() == 1) // new
@ -479,7 +479,7 @@ public class MIssue extends X_AD_Issue
}
return msg.toString();
}
return readResponse(in);
return readResponse(in);*/
} // report
/**
@ -487,7 +487,7 @@ public class MIssue extends X_AD_Issue
* @param in input stream
* @return error message
*/
private String readResponse(InputStreamReader in)
/*private String readResponse(InputStreamReader in)
{
StringBuilder sb = new StringBuilder();
int Record_ID = 0;
@ -539,7 +539,7 @@ public class MIssue extends X_AD_Issue
if (RequestDocumentNo != null)
setRequestDocumentNo(RequestDocumentNo);
return null;
} // readResponse
} // readResponse*/
/**
* String Representation

View File

@ -59,9 +59,9 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
if (checkExisting)
{
MMovementConfirm[] confirmations = move.getConfirmations(false);
for (int i = 0; i < confirmations.length; i++)
if (confirmations.length > 0)
{
MMovementConfirm confirm = confirmations[i];
MMovementConfirm confirm = confirmations[0];
return confirm;
}
}

View File

@ -50,9 +50,6 @@ public class MTemplate extends X_CM_Template
public static MTemplate get (Properties ctx, int CM_Template_ID, String trxName)
{
MTemplate retValue = new MTemplate (ctx, CM_Template_ID, trxName);
if (retValue != null)
return retValue;
retValue = new MTemplate (ctx, CM_Template_ID, null);
return retValue;
} // get

View File

@ -192,10 +192,10 @@ public final class NaturalAccountMap<K,V> extends CCache<K,V>
{
String s = st.nextToken().trim();
// Ignore, if is it header line
if (s.startsWith("[") && s.endsWith("]"))
return "";
if (s == null)
s = "";
if (s.startsWith("[") && s.endsWith("]"))
return "";
//
if (i == 0) // A - Value
Value = s;

View File

@ -1957,6 +1957,7 @@ public abstract class PO
* To reload call load() - not updated
* @return true if saved
*/
@SuppressWarnings("unused")
public boolean save()
{
CLogger.resetLast();

View File

@ -60,18 +60,18 @@ public class ArchiveEngine
// Do we need to Archive ?
MClient client = MClient.get(layout.getCtx());
String aaClient = client.getAutoArchive();
String aaRole = null; // role.getAutoArchive(); // TODO
String aa = aaClient;
if (aa == null)
aa = MClient.AUTOARCHIVE_None;
/* String aaRole = null; // role.getAutoArchive(); // TODO
if (aaRole != null)
{
if (aaRole.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
else if (aaRole.equals(MClient.AUTOARCHIVE_Documents) && !aaClient.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
}
// Mothing to Archive
}*/
// Nothing to Archive
if (aa.equals(MClient.AUTOARCHIVE_None))
return null;
// Archive External only
@ -110,18 +110,18 @@ public class ArchiveEngine
// Do we need to Archive ?
MClient client = MClient.get(Env.getCtx());
String aaClient = client.getAutoArchive();
String aaRole = null; // role.getAutoArchive(); // TODO
String aa = aaClient;
if (aa == null)
aa = MClient.AUTOARCHIVE_None;
/* String aaRole = null; // role.getAutoArchive(); // TODO
if (aaRole != null)
{
if (aaRole.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
else if (aaRole.equals(MClient.AUTOARCHIVE_Documents) && !aaClient.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
}
// Mothing to Archive
}*/
// Nothing to Archive
if (aa.equals(MClient.AUTOARCHIVE_None))
return;
// Archive External only

View File

@ -152,7 +152,7 @@ public class Secure implements SecureInterface
{
cc = Cipher.getInstance("DES/ECB/PKCS5Padding");
// Key
if (false)
/*if (false)
{
KeyGenerator keygen = KeyGenerator.getInstance("DES");
m_key = keygen.generateKey();
@ -164,7 +164,7 @@ public class Secure implements SecureInterface
sb.append(key[i]).append(",");
log.info(sb.toString());
}
else
else*/
m_key = new javax.crypto.spec.SecretKeySpec
(new byte[] {100,25,28,-122,-26,94,-3,-26}, "DES");
}

View File

@ -335,22 +335,17 @@ public class ExportFormatGenerator extends SvrProcess
tabledir = MTable.get(getCtx(), tableName);
if(tabledir==null)
return 0;
// throw new Exception ("Ilegal Table Name");
// throw new Exception ("Illegal Table Name");
formatLine.setValue(tabledir.getTableName()+"_Reference");
formatLine.setName("Referenced "+ tabledir.getTableName());
//formatLine.setType(MEXPFormatLine.TYPE_XMLElement);
if (tabledir!=null)
{
String format_value = createFormat(tabledir);
int embedded = ((MEXPFormat)m_formats.get(format_value)).getEXP_Format_ID();
formatLine.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
formatLine.setEXP_EmbeddedFormat_ID(embedded);
}
else
formatLine.setType(MEXPFormatLine.TYPE_XMLElement);
}
formatLine.setAD_Column_ID(col.getAD_Column_ID());
formatLine.saveEx();
log.info("Export Format Line:"+formatLine.getName());

View File

@ -183,14 +183,14 @@ public class DataElementHandler extends AbstractElementHandler {
}
// for debug GenericPO.
if (false) {
/*if (false) {
POInfo poInfo = POInfo.getPOInfo(ctx, get_ID(ctx, "AD_Table", d_tablename), getTrxName(ctx));
if (poInfo == null)
log.info("poInfo is null.");
for (int i = 0; i < poInfo.getColumnCount(); i++) {
log.info(d_tablename+" column: "+poInfo.getColumnName(i));
}
}
}*/
// globalqss: set AD_Client_ID to the client setted in adempieredata
if (getClientId(ctx) > 0 && genericPO.getAD_Client_ID() != getClientId(ctx))
genericPO.set_ValueOfColumn("AD_Client_ID", getClientId(ctx));

View File

@ -136,7 +136,6 @@ public class AlertProcessor extends AdempiereServer
{
if (i > 0)
message.append(Env.NL);
String trxName = null; // assume r/o
MAlertRule rule = rules[i];
if (!rule.isValid())
@ -147,7 +146,7 @@ public class AlertProcessor extends AdempiereServer
String sql = rule.getPreProcessing();
if (sql != null && sql.length() > 0)
{
int no = DB.executeUpdate(sql, false, trxName);
int no = DB.executeUpdate(sql, false, null);
if (no == -1)
{
ValueNamePair error = CLogger.retrieveError();
@ -166,9 +165,9 @@ public class AlertProcessor extends AdempiereServer
{
String text = null;
if (MSysConfig.getBooleanValue(MSysConfig.ALERT_SEND_ATTACHMENT_AS_XLS, true, Env.getAD_Client_ID(getCtx())))
text = getExcelReport(rule, sql, trxName, attachments);
text = getExcelReport(rule, sql, null, attachments);
else
text = getPlainTextReport(rule, sql, trxName, attachments);
text = getPlainTextReport(rule, sql, null, attachments);
if (text != null && text.length() > 0)
{
message.append(text);
@ -189,7 +188,7 @@ public class AlertProcessor extends AdempiereServer
sql = rule.getPostProcessing();
if (sql != null && sql.length() > 0)
{
int no = DB.executeUpdate(sql, false, trxName);
int no = DB.executeUpdate(sql, false, null);
if (no == -1)
{
ValueNamePair error = CLogger.retrieveError();
@ -202,16 +201,6 @@ public class AlertProcessor extends AdempiereServer
}
} // Post
/** Trx */
if (trxName != null)
{
Trx trx = Trx.get(trxName, false);
if (trx != null)
{
trx.commit();
trx.close();
}
}
} // for all rules
// Update header if error
@ -361,7 +350,6 @@ public class AlertProcessor extends AdempiereServer
* @param attachments (ignored)
* @return list of rows & values
* @throws Exception
* @deprecated
*/
private String getPlainTextReport(MAlertRule rule, String sql, String trxName, Collection<File> attachments)
throws Exception

View File

@ -73,10 +73,10 @@ public class FCHtmlEditorKit extends HTMLEditorKit {
// state where it thinks that image was loaded.
// ImageView is calling getImage to get image for
// measurement and painting when image was loaded
if (false) {
/*if (false) {
return getClass().getClassLoader().
getResource("javax/swing/text/html/icons/image-delayed.gif");
} else {
} else {*/
String src = (String)elem.getAttributes().
getAttribute(HTML.Attribute.SRC);
//System.out.println("img load: " + src.substring(4));
@ -86,7 +86,7 @@ public class FCHtmlEditorKit extends HTMLEditorKit {
// System.out.println("load image: " + url);
return url;
}
}
//}
return null;
}
private static Image smileImage = null;

View File

@ -701,14 +701,14 @@ public final class AdempierePLAF
try
{
Method[] methods = startClass.getMethods();
for (int i = 0; i < methods.length; i++)
if (methods.length > 0)
{
if (Modifier.isStatic(methods[i].getModifiers()) && methods[i].getName().equals("main"))
if (Modifier.isStatic(methods[0].getModifiers()) && methods[0].getName().equals("main"))
{
String[] startArgs = new String[args.length-1];
for (int ii = 1; ii < args.length; ii++)
startArgs[ii-i] = args[ii];
methods[i].invoke(null, new Object[] {startArgs});
startArgs[ii] = args[ii];
methods[0].invoke(null, new Object[] {startArgs});
}
return;
}

View File

@ -244,9 +244,9 @@ public class VTreeMaintenance extends TreeMaintenance
public void propertyChange (PropertyChangeEvent e)
{
MTreeNode tn = (MTreeNode)e.getNewValue();
log.info(tn.toString());
if (tn == null)
return;
log.info(tn.toString());
ListModel model = centerList.getModel();
int size = model.getSize();
int index = -1;

View File

@ -355,10 +355,10 @@ public final class VPanel extends CTabbedPane
fieldMinWidth = field.getPreferredSize().width > fieldMinWidth ? field.getPreferredSize().width : fieldMinWidth;
}
// Link Label to Field
if (label != null)
//if (label != null)
label.setLabelFor(field);
else if (mField.isCreateMnemonic())
setMnemonic(editor, mField.getMnemonic());
//else if (mField.isCreateMnemonic())
//setMnemonic(editor, mField.getMnemonic());
}
} // addField

View File

@ -68,8 +68,8 @@ public final class IniDialog extends JDialog implements ActionListener
log.warning("No license in resource ");
url = new URL("http://www.adempiere.org/license.htm");
}
if (url == null)
cmd_reject();
//if (url == null)
//cmd_reject();
//
licensePane.setPage(url);
AdempierePLAF.showCenterScreen(this);

View File

@ -326,10 +326,14 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener,
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Date f = fDateFrom.getValue();
Timestamp from = new Timestamp(f.getTime());
Timestamp from = null;
if (f != null)
from = new Timestamp(f.getTime());
Date t = fDateTo.getValue();
Timestamp to = new Timestamp(t.getTime());
Timestamp to = null;
if (t != null)
to = new Timestamp(t.getTime());
if (from == null && to != null)
sql.append(" AND TRUNC(c.StatementDate) <= ?");
@ -401,10 +405,14 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener,
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Date f = fDateFrom.getValue();
Timestamp from = new Timestamp(f.getTime());
Timestamp from = null;
if (f != null)
from = new Timestamp(f.getTime());
Date t = fDateTo.getValue();
Timestamp to = new Timestamp(t.getTime());
Timestamp to = null;
if (t != null)
to = new Timestamp(t.getTime());
log.fine("Date From=" + from + ", To=" + to);

View File

@ -311,10 +311,14 @@ public class InfoInOutPanel extends InfoPanel implements ValueChangeListener, Ev
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Date f = fDateFrom.getValue();
Timestamp from = new Timestamp(f.getTime());
Timestamp from = null;
if (f != null)
from = new Timestamp(f.getTime());
Date t = fDateTo.getValue();
Timestamp to = new Timestamp(t.getTime());
Timestamp to = null;
if (t != null)
to = new Timestamp(t.getTime());
if (from == null && to != null)
sql.append(" AND TRUNC(i.MovementDate) <= ?");
@ -359,10 +363,14 @@ public class InfoInOutPanel extends InfoPanel implements ValueChangeListener, Ev
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Date f = fDateFrom.getValue();
Timestamp from = new Timestamp(f.getTime());
Timestamp from = null;
if (f != null)
from = new Timestamp(f.getTime());
Date t = fDateTo.getValue();
Timestamp to = new Timestamp(t.getTime());
Timestamp to = null;
if (t != null)
to = new Timestamp(t.getTime());
log.fine("Date From=" + from + ", To=" + to);

View File

@ -45,6 +45,7 @@ import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -310,17 +311,15 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener,
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Timestamp from = null;
if (fDateFrom.getValue() != null) {
Date f = fDateFrom.getValue();
Timestamp from = null;
if (f != null)
from = new Timestamp(f.getTime());
}
Timestamp to = null;
if (fDateTo.getValue() != null) {
Date t = fDateTo.getValue();
Timestamp to = null;
if (t != null)
to = new Timestamp(t.getTime());
}
if (from == null && to != null)
sql.append(" AND TRUNC(p.DateTrx) <= ?");
@ -332,8 +331,25 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener,
if (!"".equals(fAmtFrom.getText()) || !"".equals(fAmtTo.getText()))
{
BigDecimal from = new BigDecimal(fAmtFrom.getValue());
BigDecimal to = new BigDecimal(fAmtTo.getValue());
String f = fAmtFrom.getValue();
BigDecimal from = null;
if (f != null) {
try {
from = new BigDecimal(fAmtFrom.getValue());
} catch (NumberFormatException e) {
fAmtFrom.setValue(null);
}
}
String t = fAmtTo.getValue();
BigDecimal to = null;
if (t != null) {
try {
to = new BigDecimal(fAmtTo.getValue());
} catch (NumberFormatException e) {
fAmtTo.setValue(null);
}
}
if (from == null && to != null)
sql.append(" AND p.PayAmt <= ?");
@ -373,17 +389,15 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener,
if (fDateFrom.getValue() != null || fDateTo.getValue() != null)
{
Timestamp from = null;
if (fDateFrom.getValue() != null) {
Date f = fDateFrom.getValue();
Timestamp from = null;
if (f != null)
from = new Timestamp(f.getTime());
}
Timestamp to = null;
if (fDateTo.getValue() != null) {
Date t = fDateTo.getValue();
Timestamp to = null;
if (t != null)
to = new Timestamp(t.getTime());
}
log.fine("Date From=" + from + ", To=" + to);
@ -400,8 +414,26 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener,
if (!"".equals(fAmtFrom.getText()) || !"".equals(fAmtTo.getText()))
{
BigDecimal from = new BigDecimal(fAmtFrom.getValue());
BigDecimal to = new BigDecimal(fAmtTo.getValue());
String f = fAmtFrom.getValue();
BigDecimal from = null;
if (f != null) {
try {
from = new BigDecimal(fAmtFrom.getValue());
} catch (NumberFormatException e) {
fAmtFrom.setValue(null);
}
}
String t = fAmtTo.getValue();
BigDecimal to = null;
if (t != null) {
try {
to = new BigDecimal(fAmtTo.getValue());
} catch (NumberFormatException e) {
fAmtTo.setValue(null);
}
}
log.fine("Amt From=" + from + ", To=" + to);
if (from == null && to != null)