IDEMPIERE-4652 Remove Eclipse warnings (#533)

This commit is contained in:
hengsin 2021-01-19 00:32:25 +08:00 committed by GitHub
parent 0cfa1c182a
commit 1afe4fe0c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 71 additions and 183 deletions

View File

@ -349,15 +349,12 @@ public class CommissionCalc extends SvrProcess
*/
private void createDetail (String sql, MCommissionAmt comAmt) throws Exception
{
PreparedStatement pstmt = null;
ResultSet rs = null;
try
try (PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());)
{
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, m_com.getAD_Client_ID());
pstmt.setTimestamp(2, p_StartDate);
pstmt.setTimestamp(3, m_EndDate);
rs = pstmt.executeQuery();
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
// CommissionAmount, C_Currency_ID, Amt, Qty,
@ -388,11 +385,6 @@ public class CommissionCalc extends SvrProcess
{
throw new AdempiereSystemError("System Error: " + e.getLocalizedMessage(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
} // createDetail
} // CommissionCalc

View File

@ -95,12 +95,9 @@ public class ExpenseAPInvoice extends SvrProcess
//
int old_BPartner_ID = -1;
MInvoice invoice = null;
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString (), get_TrxName());
//
try (PreparedStatement pstmt = DB.prepareStatement (sql.toString (), get_TrxName());)
{
int par = 1;
pstmt.setInt(par++, getAD_Client_ID());
if (m_C_BPartner_ID != 0)
@ -109,7 +106,7 @@ public class ExpenseAPInvoice extends SvrProcess
pstmt.setTimestamp (par++, m_DateFrom);
if (m_DateTo != null)
pstmt.setTimestamp (par++, m_DateTo);
rs = pstmt.executeQuery ();
ResultSet rs = pstmt.executeQuery ();
while (rs.next()) // ********* Expense Line Loop
{
MTimeExpense te = new MTimeExpense (getCtx(), rs, get_TrxName());
@ -201,11 +198,6 @@ public class ExpenseAPInvoice extends SvrProcess
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
completeInvoice (invoice);
StringBuilder msgreturn = new StringBuilder("@Created@=").append(m_noInvoices);
return msgreturn.toString();

View File

@ -351,12 +351,9 @@ public class ImportInventory extends SvrProcess implements ImportProcess
sql = new StringBuilder ("SELECT * FROM I_Inventory ")
.append("WHERE I_IsImported='N'").append (clientCheck)
.append(" ORDER BY M_Warehouse_ID, TRUNC(MovementDate), I_Inventory_ID");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
try (PreparedStatement pstmt = DB.prepareStatement (sql.toString (), get_TrxName());)
{
pstmt = DB.prepareStatement (sql.toString (), get_TrxName());
rs = pstmt.executeQuery ();
ResultSet rs = pstmt.executeQuery ();
//
int x_M_Warehouse_ID = -1;
int x_C_DocType_ID = -1;
@ -487,11 +484,6 @@ public class ImportInventory extends SvrProcess implements ImportProcess
{
throw new AdempiereException(e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
// Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_Inventory ")

View File

@ -412,13 +412,11 @@ public class ImportPayment extends SvrProcess
.append(" ORDER BY C_BankAccount_ID, CheckNo, DateTrx, R_AuthCode");
MBankAccount account = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int noInsert = 0;
try
try (PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());)
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery();
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
@ -520,12 +518,6 @@ public class ImportPayment extends SvrProcess
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Set Error to indicator to not imported
sql = new StringBuilder ("UPDATE I_Payment ")

View File

@ -223,12 +223,9 @@ public class PaySelectionCreateFrom extends SvrProcess
sql.append(sqlWhere.toString());
//
int lines = 0;
int C_CurrencyTo_ID = psel.getC_Currency_ID();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
int C_CurrencyTo_ID = psel.getC_Currency_ID();
try (PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName());)
{
int index = 1;
pstmt.setInt (index++, C_CurrencyTo_ID);
pstmt.setTimestamp(index++, psel.getPayDate());
@ -267,7 +264,7 @@ public class PaySelectionCreateFrom extends SvrProcess
pstmt.setInt (index++, p_C_BP_Group_ID);
}
//
rs = pstmt.executeQuery ();
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
{
int C_Invoice_ID = rs.getInt(1);
@ -301,12 +298,6 @@ public class PaySelectionCreateFrom extends SvrProcess
{
throw new AdempiereException(e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
StringBuilder msgreturn = new StringBuilder("@C_PaySelectionLine_ID@ - #").append(lines);
return msgreturn.toString();
} // doIt

View File

@ -100,13 +100,10 @@ public class SequenceCheck extends SvrProcess
+ "FROM AD_Table t "
+ "WHERE IsActive='Y' AND IsView='N'"
+ " AND NOT EXISTS (SELECT * FROM AD_Sequence s "
+ "WHERE UPPER(s.Name)=UPPER(t.TableName) AND s.IsTableID='Y')";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
rs = pstmt.executeQuery();
+ "WHERE UPPER(s.Name)=UPPER(t.TableName) AND s.IsTableID='Y')";
try (PreparedStatement pstmt = DB.prepareStatement(sql, trxName);)
{
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
String tableName = rs.getString(1);
@ -128,11 +125,6 @@ public class SequenceCheck extends SvrProcess
s_log.log(Level.SEVERE, sql, e);
throw new AdempiereException(e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
// Sync Table Name case
sql = "UPDATE AD_Sequence s "
@ -161,10 +153,9 @@ public class SequenceCheck extends SvrProcess
+ "WHERE t.IsActive='Y' AND t.IsView='N'"
+ " AND UPPER(s.Name)=UPPER(t.TableName) AND s.Name<>t.TableName";
//
try
{
pstmt = DB.prepareStatement (sql, null);
rs = pstmt.executeQuery ();
try (PreparedStatement pstmt = DB.prepareStatement (sql, null);)
{
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
{
String TableName = rs.getString(1);
@ -178,11 +169,6 @@ public class SequenceCheck extends SvrProcess
s_log.log (Level.SEVERE, sql, e);
throw new AdempiereException(e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
} // checkTableSequences

View File

@ -39,7 +39,6 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im
*/
//m_stream is not closed because the BufferedReader in the parent class is closed and according to the Java docs:
//Calling close() on the BufferedReader closes the underlying stream by default implementation
@SuppressWarnings("resource")
public boolean init(MBankStatementLoader controller)
{
boolean result = false;

View File

@ -1618,14 +1618,11 @@ public class GridTable extends AbstractTableModel
if (m_inserting)
select.append(" WHERE 1=2");
else // FOR UPDATE causes - ORA-01002 fetch out of sequence
select.append(" WHERE ").append(getWhereClause(rowData));
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (select.toString(),
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, null);
rs = pstmt.executeQuery();
select.append(" WHERE ").append(getWhereClause(rowData));
try (PreparedStatement pstmt = DB.prepareStatement (select.toString(),
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, null);)
{
ResultSet rs = pstmt.executeQuery();
// only one row
if (!(m_inserting || rs.next()))
{
@ -2071,10 +2068,6 @@ public class GridTable extends AbstractTableModel
rs.updateRow();
}
log.fine("Committing ...");
DB.commit(true, null); // no Trx
DB.close(rs, pstmt);
rs = null; pstmt = null;
//
lobSave(whereClause);
@ -2082,29 +2075,31 @@ public class GridTable extends AbstractTableModel
if (log.isLoggable(Level.FINE)) log.fine("Reading ... " + whereClause);
StringBuilder refreshSQL = new StringBuilder(m_SQL_Select)
.append(" WHERE ").append(whereClause);
pstmt = DB.prepareStatement(refreshSQL.toString(), null);
rs = pstmt.executeQuery();
if (rs.next())
try (PreparedStatement pstmt1 = DB.prepareStatement(refreshSQL.toString(), null);)
{
rowDataDB = readData(rs);
// update buffer
setDataAtRow(m_rowChanged, rowDataDB);
if (m_virtual)
rs = pstmt1.executeQuery();
if (rs.next())
{
MSort sort = m_sort.get(m_rowChanged);
int oldId = sort.index;
int newId = getKeyID(m_rowChanged);
if (newId != oldId)
rowDataDB = readData(rs);
// update buffer
setDataAtRow(m_rowChanged, rowDataDB);
if (m_virtual)
{
sort.index = newId;
Object[] data = m_virtualBuffer.remove(oldId);
m_virtualBuffer.put(newId, data);
MSort sort = m_sort.get(m_rowChanged);
int oldId = sort.index;
int newId = getKeyID(m_rowChanged);
if (newId != oldId)
{
sort.index = newId;
Object[] data = m_virtualBuffer.remove(oldId);
m_virtualBuffer.put(newId, data);
}
}
fireTableRowsUpdated(m_rowChanged, m_rowChanged);
}
fireTableRowsUpdated(m_rowChanged, m_rowChanged);
else
log.log(Level.SEVERE, "Inserted row not found");
}
else
log.log(Level.SEVERE, "Inserted row not found");
//
}
catch (Exception e)
@ -2122,12 +2117,6 @@ public class GridTable extends AbstractTableModel
fireDataStatusEEvent(msg, e.getLocalizedMessage(), true);
return SAVE_ERROR;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
CacheMgt.get().reset(m_tableName);

View File

@ -1832,7 +1832,6 @@ public class MPayment extends X_C_Payment
protected String m_processMsg = null;
/** Just Prepared Flag */
protected boolean m_justPrepared = false;
@SuppressWarnings("unused")
protected IProcessUI m_processUI;
/**

View File

@ -32,7 +32,6 @@ public class MProduction extends X_M_Production implements DocAction {
*
*/
/** Log */
@SuppressWarnings("unused")
protected static CLogger m_log = CLogger.getCLogger (MProduction.class);
protected int lineno;
protected int count;
@ -260,14 +259,10 @@ public class MProduction extends X_M_Production implements DocAction {
// products used in production
String sql = "SELECT M_ProductBom_ID, BOMQty" + " FROM M_Product_BOM"
+ " WHERE M_Product_ID=" + finishedProduct.getM_Product_ID() + " ORDER BY Line";
try (PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());) {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, get_TrxName());
rs = pstmt.executeQuery();
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
lineno = lineno + 10;
@ -432,9 +427,6 @@ public class MProduction extends X_M_Production implements DocAction {
} catch (Exception e) {
throw new AdempiereException("Failed to create production lines", e);
}
finally {
DB.close(rs, pstmt);
}
return count;
}

View File

@ -126,14 +126,10 @@ public class MProductionPlan extends X_M_ProductionPlan {
// products used in production
String sql = "SELECT M_ProductBom_ID, BOMQty" + " FROM M_Product_BOM"
+ " WHERE M_Product_ID=" + finishedProduct.getM_Product_ID() + " ORDER BY Line";
try (PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());) {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, get_TrxName());
rs = pstmt.executeQuery();
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
lineno = lineno + 10;
@ -298,9 +294,6 @@ public class MProductionPlan extends X_M_ProductionPlan {
} catch (Exception e) {
throw new AdempiereException("Failed to create production lines", e);
}
finally {
DB.close(rs, pstmt);
}
return count;
}

View File

@ -136,16 +136,13 @@ public class CashFlow extends SvrProcess {
"cp.C_CashPlan_ID " +
"FROM C_CashPlanLine cpl " +
"JOIN C_CashPlan cp ON (cp.C_CashPlan_ID=cpl.C_CashPlan_ID) " +
"WHERE cp.AD_Client_ID=? AND cp.IsActive='Y' AND cpl.IsActive='Y' AND cpl.DateTrx BETWEEN ? AND ?";
PreparedStatement pstmtPlan = null;
ResultSet rsPlan = null;
try
{
pstmtPlan = DB.prepareStatement(sqlPlan, get_TrxName());
"WHERE cp.AD_Client_ID=? AND cp.IsActive='Y' AND cpl.IsActive='Y' AND cpl.DateTrx BETWEEN ? AND ?";
try (PreparedStatement pstmtPlan = DB.prepareStatement(sqlPlan, get_TrxName());)
{
pstmtPlan.setInt(1, getAD_Client_ID());
pstmtPlan.setTimestamp(2, p_dateFrom);
pstmtPlan.setTimestamp(3, p_dateTo);
rsPlan = pstmtPlan.executeQuery();
ResultSet rsPlan = pstmtPlan.executeQuery();
int noPlan = 0;
while (rsPlan.next())
{
@ -185,25 +182,17 @@ public class CashFlow extends SvrProcess {
{
log.log(Level.SEVERE, sqlPlan, e);
}
finally
{
DB.close(rsPlan, pstmtPlan);
rsPlan = null; pstmtPlan = null;
}
/* commitment records */
String sqlOpenOrders = "SELECT o.C_Order_ID, o.IsPayScheduleValid, " +
"SUM((ol.QtyOrdered-ol.QtyInvoiced)*ol.PriceActual)/o.TotalLines as Pending " +
"FROM C_Order o JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID) " +
"WHERE o.AD_Client_ID=? AND o.TotalLines != 0 AND o.DocStatus IN ('CO') AND ol.QtyInvoiced<ol.QtyOrdered " +
"GROUP BY o.C_Order_ID, o.IsPayScheduleValid, o.TotalLines";
PreparedStatement pstmtOpenOrders = null;
ResultSet rsOpenOrders = null;
try
{
pstmtOpenOrders = DB.prepareStatement(sqlOpenOrders, get_TrxName());
"GROUP BY o.C_Order_ID, o.IsPayScheduleValid, o.TotalLines";
try (PreparedStatement pstmtOpenOrders = DB.prepareStatement(sqlOpenOrders, get_TrxName());)
{
pstmtOpenOrders.setInt(1, getAD_Client_ID());
rsOpenOrders = pstmtOpenOrders.executeQuery();
ResultSet rsOpenOrders = pstmtOpenOrders.executeQuery();
int noOrders = 0;
int noOrdIns = 0;
int noOrdSchIns = 0;
@ -310,25 +299,17 @@ public class CashFlow extends SvrProcess {
{
log.log(Level.SEVERE, sqlOpenOrders, e);
}
finally
{
DB.close(rsOpenOrders, pstmtOpenOrders);
rsOpenOrders = null; pstmtOpenOrders = null;
}
/* actual records */
String sqlActual = "SELECT oi.AD_Org_ID, oi.C_Invoice_ID, oi.C_BPartner_ID, oi.IsSOTrx, oi.DueDate, oi.OpenAmt, oi.C_Campaign_ID, oi.C_Project_ID, oi.C_Activity_ID " +
"FROM RV_OpenItem oi " +
"WHERE oi.AD_Client_ID=? AND oi.DueDate <= ?";
PreparedStatement pstmtActual = null;
ResultSet rsActual = null;
try
{
pstmtActual = DB.prepareStatement(sqlActual, get_TrxName());
"WHERE oi.AD_Client_ID=? AND oi.DueDate <= ?";
try (PreparedStatement pstmtActual = DB.prepareStatement(sqlActual, get_TrxName());)
{
pstmtActual.setInt(1, getAD_Client_ID());
pstmtActual.setTimestamp(2, p_dateTo);
rsActual = pstmtActual.executeQuery();
ResultSet rsActual = pstmtActual.executeQuery();
int noInv = 0;
while (rsActual.next())
{
@ -367,11 +348,6 @@ public class CashFlow extends SvrProcess {
{
log.log(Level.SEVERE, sqlActual, e);
}
finally
{
DB.close(rsActual, pstmtActual);
rsActual = null; pstmtActual = null;
}
/* subtract from plan lines the related orders */
String sqlupdord = "UPDATE T_CashFlow " +

View File

@ -53,7 +53,7 @@ public class ServletContextAdaptor implements ServletContext {
return null;
try {
Method getResourcePathsMethod = httpContext.getClass().getMethod("getResourcePaths", new Class[] {String.class}); //$NON-NLS-1$
if (!getResourcePathsMethod.isAccessible())
if (!getResourcePathsMethod.canAccess(httpContext))
getResourcePathsMethod.setAccessible(true);
return (Set<String>) getResourcePathsMethod.invoke(httpContext, new Object[] {name});
} catch (Exception e) {

View File

@ -133,13 +133,10 @@ public class GenericPOElementHandler extends AbstractElementHandler {
int tableId = Env.getContextAsInt(ctx.ctx, DataElementParameters.AD_TABLE_ID);
String tableName = MTable.getTableName(ctx.ctx, tableId);
List<String> excludes = defaultExcludeList(tableName);
boolean checkExcluded = ! sql.toLowerCase().startsWith("select *");
Statement stmt = null;
ResultSet rs = null;
try {
sql = MRole.getDefault().addAccessSQL(sql, tableName, true, true);
stmt = DB.createStatement();
rs = stmt.executeQuery(sql);
boolean checkExcluded = ! sql.toLowerCase().startsWith("select *");
try (Statement stmt = DB.createStatement();) {
sql = MRole.getDefault().addAccessSQL(sql, tableName, true, true);
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
GenericPO po = new GenericPO(tableName, ctx.ctx, rs, getTrxName(ctx));
int AD_Client_ID = po.getAD_Client_ID();
@ -212,8 +209,6 @@ public class GenericPOElementHandler extends AbstractElementHandler {
}
} catch (Exception e) {
throw new AdempiereException(e);
} finally {
DB.close(rs, stmt);
}
}

View File

@ -21,6 +21,7 @@ import java.lang.ref.WeakReference;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Properties;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@ -459,7 +460,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
clientInfo.desktopXOffset = c.getDesktopXOffset();
clientInfo.desktopYOffset = c.getDesktopYOffset();
clientInfo.orientation = c.getOrientation();
clientInfo.timeZone = c.getTimeZone();
clientInfo.timeZone = TimeZone.getTimeZone(c.getZoneId());
String ua = Servlets.getUserAgent((ServletRequest) Executions.getCurrent().getNativeRequest());
clientInfo.userAgent = ua;
ua = ua.toLowerCase();

View File

@ -358,7 +358,6 @@ public class FDialog
}
public static void askForInput(final String message, MLookup lookup, int editorType, final Callback<Object> callback, Desktop desktop, int windowNo) {
@SuppressWarnings("unused")
final WEditor weditor;
switch (editorType) {