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

@ -96,11 +96,8 @@ public class ExpenseAPInvoice extends SvrProcess
int old_BPartner_ID = -1;
MInvoice invoice = null;
//
PreparedStatement pstmt = null;
ResultSet rs = null;
try
try (PreparedStatement pstmt = DB.prepareStatement (sql.toString (), get_TrxName());)
{
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

@ -224,11 +224,8 @@ public class PaySelectionCreateFrom extends SvrProcess
//
int lines = 0;
int C_CurrencyTo_ID = psel.getC_Currency_ID();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
try (PreparedStatement pstmt = DB.prepareStatement (sql.toString(), get_TrxName());)
{
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

@ -101,12 +101,9 @@ public class SequenceCheck extends SvrProcess
+ "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
try (PreparedStatement pstmt = DB.prepareStatement(sql, trxName);)
{
pstmt = DB.prepareStatement(sql, trxName);
rs = pstmt.executeQuery();
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
try (PreparedStatement pstmt = DB.prepareStatement (sql, null);)
{
pstmt = DB.prepareStatement (sql, null);
rs = pstmt.executeQuery ();
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

@ -1619,13 +1619,10 @@ public class GridTable extends AbstractTableModel
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
try (PreparedStatement pstmt = DB.prepareStatement (select.toString(),
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, null);)
{
pstmt = DB.prepareStatement (select.toString(),
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, null);
rs = pstmt.executeQuery();
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,8 +2075,9 @@ 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();
try (PreparedStatement pstmt1 = DB.prepareStatement(refreshSQL.toString(), null);)
{
rs = pstmt1.executeQuery();
if (rs.next())
{
rowDataDB = readData(rs);
@ -2105,6 +2099,7 @@ public class GridTable extends AbstractTableModel
}
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;
@ -261,13 +260,9 @@ public class MProduction extends X_M_Production implements DocAction {
String sql = "SELECT M_ProductBom_ID, BOMQty" + " FROM M_Product_BOM"
+ " WHERE M_Product_ID=" + finishedProduct.getM_Product_ID() + " ORDER BY Line";
PreparedStatement pstmt = null;
ResultSet rs = null;
try (PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());) {
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

@ -127,13 +127,9 @@ public class MProductionPlan extends X_M_ProductionPlan {
String sql = "SELECT M_ProductBom_ID, BOMQty" + " FROM M_Product_BOM"
+ " WHERE M_Product_ID=" + finishedProduct.getM_Product_ID() + " ORDER BY Line";
PreparedStatement pstmt = null;
ResultSet rs = null;
try (PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());) {
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

@ -137,15 +137,12 @@ public class CashFlow extends SvrProcess {
"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
try (PreparedStatement pstmtPlan = DB.prepareStatement(sqlPlan, get_TrxName());)
{
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,11 +182,6 @@ 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, " +
@ -197,13 +189,10 @@ public class CashFlow extends SvrProcess {
"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
try (PreparedStatement pstmtOpenOrders = DB.prepareStatement(sqlOpenOrders, get_TrxName());)
{
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
try (PreparedStatement pstmtActual = DB.prepareStatement(sqlActual, get_TrxName());)
{
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

@ -134,12 +134,9 @@ public class GenericPOElementHandler extends AbstractElementHandler {
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 {
try (Statement stmt = DB.createStatement();) {
sql = MRole.getDefault().addAccessSQL(sql, tableName, true, true);
stmt = DB.createStatement();
rs = stmt.executeQuery(sql);
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) {