IDEMPIERE-455 Discover and fix FindBugs problems / Patterns Multithreaded correctness

This commit is contained in:
Carlos Ruiz 2012-12-17 20:32:05 -05:00
parent 7516e37f1f
commit d3e8ef0a7a
39 changed files with 50 additions and 50 deletions

View File

@ -66,7 +66,7 @@ public class DocManager {
return documentsTableName; return documentsTableName;
} }
private static void fillDocumentsTableArrays() { private synchronized static void fillDocumentsTableArrays() {
if (documentsTableID == null) { if (documentsTableID == null) {
String sql = "SELECT t.AD_Table_ID, t.TableName " + String sql = "SELECT t.AD_Table_ID, t.TableName " +
"FROM AD_Table t, AD_Column c " + "FROM AD_Table t, AD_Column c " +

View File

@ -48,7 +48,7 @@ public class CConnection implements Serializable, Cloneable
*/ */
private static final long serialVersionUID = -7893119456331485444L; private static final long serialVersionUID = -7893119456331485444L;
/** Connection */ /** Connection */
private static CConnection s_cc = null; private volatile static CConnection s_cc = null;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger (CConnection.class); private static CLogger log = CLogger.getCLogger (CConnection.class);
@ -86,7 +86,7 @@ public class CConnection implements Serializable, Cloneable
* @param apps_host optional apps host for new connections * @param apps_host optional apps host for new connections
* @return Connection Descriptor * @return Connection Descriptor
*/ */
public static CConnection get (String apps_host) public synchronized static CConnection get (String apps_host)
{ {
if (s_cc == null) if (s_cc == null)
{ {
@ -1418,7 +1418,7 @@ public class CConnection implements Serializable, Cloneable
* Get Last Exception of Apps Server Connection attempt * Get Last Exception of Apps Server Connection attempt
* @return Exception or null * @return Exception or null
*/ */
public Exception getAppsServerException () public synchronized Exception getAppsServerException ()
{ {
return m_appsException; return m_appsException;
} // getAppsServerException } // getAppsServerException

View File

@ -432,7 +432,7 @@ public abstract class Convert
*/ */
public abstract boolean isOracle(); public abstract boolean isOracle();
public static void logMigrationScript(String oraStatement, String pgStatement) { public synchronized static void logMigrationScript(String oraStatement, String pgStatement) {
// Check AdempiereSys // Check AdempiereSys
// check property Log migration script // check property Log migration script
boolean logMigrationScript = false; boolean logMigrationScript = false;

View File

@ -51,7 +51,7 @@ public class MEXPProcessor extends X_EXP_Processor {
/** Static Logger */ /** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MEXPProcessor.class); private static CLogger s_log = CLogger.getCLogger (MEXPProcessor.class);
private static MEXPProcessor processor= null; private volatile static MEXPProcessor processor= null;
private X_EXP_ProcessorParameter[] parameters = null; private X_EXP_ProcessorParameter[] parameters = null;
public static MEXPProcessor get(Properties ctx, int EXP_Processor_ID, String trxName) public static MEXPProcessor get(Properties ctx, int EXP_Processor_ID, String trxName)

View File

@ -186,7 +186,7 @@ public class MLocator extends X_M_Locator
} // get } // get
/** Cache */ /** Cache */
private static CCache<Integer,MLocator> s_cache; private volatile static CCache<Integer,MLocator> s_cache;
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MLocator.class); private static CLogger s_log = CLogger.getCLogger (MLocator.class);

View File

@ -196,7 +196,7 @@ public class MRequestType extends X_R_RequestType
* Get Total No of requests of type * Get Total No of requests of type
* @return no * @return no
*/ */
public int getTotalNo() public synchronized int getTotalNo()
{ {
updateStatistics(); updateStatistics();
return m_totalNo; return m_totalNo;
@ -206,7 +206,7 @@ public class MRequestType extends X_R_RequestType
* Get Open No of requests of type * Get Open No of requests of type
* @return no * @return no
*/ */
public int getOpenNo() public synchronized int getOpenNo()
{ {
updateStatistics(); updateStatistics();
return m_openNo; return m_openNo;
@ -216,7 +216,7 @@ public class MRequestType extends X_R_RequestType
* Get Closed in last 30 days of type * Get Closed in last 30 days of type
* @return no * @return no
*/ */
public int getClosed30No() public synchronized int getClosed30No()
{ {
updateStatistics(); updateStatistics();
return m_closed30No; return m_closed30No;
@ -226,7 +226,7 @@ public class MRequestType extends X_R_RequestType
* Get New in the last 30 days of type * Get New in the last 30 days of type
* @return no * @return no
*/ */
public int getNew30No() public synchronized int getNew30No()
{ {
updateStatistics(); updateStatistics();
return m_new30No; return m_new30No;

View File

@ -62,7 +62,7 @@ public class MSystem extends X_AD_System
* @param ctx context * @param ctx context
* @return System * @return System
*/ */
public static MSystem get (Properties ctx) public synchronized static MSystem get (Properties ctx)
{ {
if (s_system != null) if (s_system != null)
return s_system; return s_system;

View File

@ -35,7 +35,7 @@ public class MUserDefWin extends X_AD_UserDef_Win
*/ */
private static final long serialVersionUID = -5775251886672840324L; private static final long serialVersionUID = -5775251886672840324L;
private static List<MUserDefWin> m_fullList = null; private volatile static List<MUserDefWin> m_fullList = null;
/** /**
* Standard constructor. * Standard constructor.

View File

@ -65,7 +65,7 @@ public class TranslationTable
* @param requery requery * @param requery requery
* @return number of active Translations * @return number of active Translations
*/ */
public static int getActiveLanguages (boolean requery) public synchronized static int getActiveLanguages (boolean requery)
{ {
if (s_activeLanguages != null && !requery) if (s_activeLanguages != null && !requery)
return s_activeLanguages.intValue(); return s_activeLanguages.intValue();

View File

@ -195,7 +195,7 @@ public class ArchiveEngine
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(ArchiveEngine.class); private static CLogger log = CLogger.getCLogger(ArchiveEngine.class);
/** Singleton */ /** Singleton */
private static ArchiveEngine s_engine = null; private volatile static ArchiveEngine s_engine = null;
/************************************************************************** /**************************************************************************

View File

@ -171,7 +171,7 @@ public class SwapFile
freeBlocks(segment.getOffsets()); freeBlocks(segment.getOffsets());
} }
private void verifyOpen() { private synchronized void verifyOpen() {
if (randomAccessFile == null) { if (randomAccessFile == null) {
throw new RuntimeException("Swap file not open for read write access"); throw new RuntimeException("Swap file not open for read write access");
} }

View File

@ -52,7 +52,7 @@ public class CCachedRowSet extends CachedRowSetImpl implements CachedRowSet
* @return Cached Row Set * @return Cached Row Set
* @throws SQLException * @throws SQLException
*/ */
public static CCachedRowSet get() throws SQLException public synchronized static CCachedRowSet get() throws SQLException
{ {
CCachedRowSet crs = null; CCachedRowSet crs = null;
// only first time call // only first time call

View File

@ -116,7 +116,7 @@ public class CLogger extends Logger implements Serializable
} // get } // get
/** Default Logger */ /** Default Logger */
private static CLogger s_logger = null; private volatile static CLogger s_logger = null;
/************************************************************************** /**************************************************************************

View File

@ -255,7 +255,7 @@ public final class DB
* Set connection * Set connection
* @param cc connection * @param cc connection
*/ */
public static void setDBTarget (CConnection cc) public synchronized static void setDBTarget (CConnection cc)
{ {
if (cc == null) if (cc == null)
throw new IllegalArgumentException("Connection is NULL"); throw new IllegalArgumentException("Connection is NULL");

View File

@ -224,7 +224,7 @@ public final class Ini implements Serializable
}; };
/** Container for Properties */ /** Container for Properties */
private static Properties s_prop = new Properties(); private volatile static Properties s_prop = new Properties();
private static String s_propertyFileName = null; private static String s_propertyFileName = null;

View File

@ -217,7 +217,7 @@ public class SecureEngine
/** Test String */ /** Test String */
private static final String TEST = "This is a 0123456789 .,; -= Test!"; private static final String TEST = "This is a 0123456789 .,; -= Test!";
/** Secure Engine */ /** Secure Engine */
private static SecureEngine s_engine = null; private volatile static SecureEngine s_engine = null;
/** The real Engine */ /** The real Engine */
private SecureInterface implementation = null; private SecureInterface implementation = null;

View File

@ -64,7 +64,7 @@ public class WebInfo
} // getGeneral } // getGeneral
/** General Info */ /** General Info */
private static WebInfo m_general = null; private volatile static WebInfo m_general = null;
/** /**
* Constructor * Constructor

View File

@ -107,7 +107,7 @@ public class WebUser
} // get } // get
/** Short term Cache for immediate re-query/post (hit rate 20%) */ /** Short term Cache for immediate re-query/post (hit rate 20%) */
private static WebUser s_cache = null; private volatile static WebUser s_cache = null;
/*************************************************************************/ /*************************************************************************/

View File

@ -55,7 +55,7 @@ public class DocWorkflowManager implements DocWorkflowMgr
} }
/** Document Workflow Manager */ /** Document Workflow Manager */
private static DocWorkflowManager s_mgr = null; private volatile static DocWorkflowManager s_mgr = null;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(DocWorkflowManager.class); private static CLogger log = CLogger.getCLogger(DocWorkflowManager.class);

View File

@ -50,7 +50,7 @@ public class HttpServiceImpl implements HttpService, ExtendedHttpService {
shutdown = true; shutdown = true;
} }
private void checkShutdown() { private synchronized void checkShutdown() {
if (shutdown) if (shutdown)
throw new IllegalStateException("Service instance is already shutdown"); //$NON-NLS-1$ throw new IllegalStateException("Service instance is already shutdown"); //$NON-NLS-1$
} }

View File

@ -42,7 +42,7 @@ public class ProxyServlet extends HttpServlet implements Filter {
Activator.addProxyServlet(this); Activator.addProxyServlet(this);
} }
public void destroy() { public synchronized void destroy() {
Activator.removeProxyServlet(this); Activator.removeProxyServlet(this);
proxyContext.destroy(); proxyContext.destroy();
proxyContext = null; proxyContext = null;
@ -56,7 +56,7 @@ public class ProxyServlet extends HttpServlet implements Filter {
process(req, resp, null); process(req, resp, null);
} }
protected void process(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException { protected synchronized void process(HttpServletRequest req, HttpServletResponse resp, FilterChain filterChain) throws ServletException, IOException {
proxyContext.initializeServletPath(req, filterChain); proxyContext.initializeServletPath(req, filterChain);
String alias = HttpServletRequestAdaptor.getDispatchPathInfo(req, filterChain); String alias = HttpServletRequestAdaptor.getDispatchPathInfo(req, filterChain);
if (alias == null) if (alias == null)

View File

@ -35,7 +35,7 @@ public class BridgeServlet extends HttpServlet {
private static HttpServlet servletDelegateInstance; private static HttpServlet servletDelegateInstance;
private HttpServlet delegate; private HttpServlet delegate;
// true if current HttpServlet is an HTTP Filter and false otherwise. // true if current HttpServlet is an HTTP Filter and false otherwise.
private boolean delegateIsFilter; private static boolean delegateIsFilter;
private int delegateReferenceCount; private int delegateReferenceCount;
/** /**
@ -175,7 +175,7 @@ public class BridgeServlet extends HttpServlet {
try { try {
// cache the flag if HttpServlet servlet delegate is an HTTP Filter. // cache the flag if HttpServlet servlet delegate is an HTTP Filter.
instance.delegateIsFilter = (servletDelegate instanceof Filter); BridgeServlet.delegateIsFilter = (servletDelegate instanceof Filter);
// initialize the servlet delegate. // initialize the servlet delegate.
servletDelegate.init(instance.getServletConfig()); servletDelegate.init(instance.getServletConfig());
} catch (ServletException e) { } catch (ServletException e) {
@ -207,7 +207,7 @@ public class BridgeServlet extends HttpServlet {
HttpServlet oldProxy = instance.delegate; HttpServlet oldProxy = instance.delegate;
instance.delegate = null; instance.delegate = null;
instance.delegateIsFilter = false; BridgeServlet.delegateIsFilter = false;
while (instance.delegateReferenceCount != 0) { while (instance.delegateReferenceCount != 0) {
try { try {
instance.wait(); instance.wait();

View File

@ -38,7 +38,7 @@ public class AdempiereServerGroup extends ThreadGroup
} // get } // get
/** Group */ /** Group */
private static AdempiereServerGroup s_group = null; private volatile static AdempiereServerGroup s_group = null;
/** /**
* AdempiereServerGroup * AdempiereServerGroup

View File

@ -94,11 +94,11 @@ public class AdempiereMonitor extends HttpServlet
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(AdempiereMonitor.class); private static CLogger log = CLogger.getCLogger(AdempiereMonitor.class);
/** The Server */ /** The Server */
private AdempiereServerMgr m_serverMgr = null; private static AdempiereServerMgr m_serverMgr = null;
/** Message */ /** Message */
private p m_message = null; private static p m_message = null;
private ArrayList<File> m_dirAccessList = null; private volatile static ArrayList<File> m_dirAccessList = null;
/** /**
* Get * Get

View File

@ -146,7 +146,7 @@ public final class VAccountDialog extends CDialog
protected boolean m_changed = false; protected boolean m_changed = false;
/** Accounting Schema */ /** Accounting Schema */
private static MAcctSchema s_AcctSchema = null; private volatile static MAcctSchema s_AcctSchema = null;
/** MWindow for AccountCombination */ /** MWindow for AccountCombination */
private GridWindow m_mWindow = null; private GridWindow m_mWindow = null;
/** MTab for AccountCombination */ /** MTab for AccountCombination */

View File

@ -90,7 +90,7 @@ public class AtmosphereServerPush implements ServerPush {
synchronized (info) { synchronized (info) {
info.nActive = 1; //granted info.nActive = 1; //granted
info.notify(); info.notifyAll();
} }
try { try {
@ -145,7 +145,7 @@ public class AtmosphereServerPush implements ServerPush {
_active = null; _active = null;
synchronized (_mutex) { synchronized (_mutex) {
_mutex.notify(); _mutex.notifyAll();
} }
} }
} }

View File

@ -123,7 +123,7 @@ public final class WAccountDialog extends Window
protected boolean m_changed = false; protected boolean m_changed = false;
/** Accounting Schema */ /** Accounting Schema */
private static MAcctSchema s_AcctSchema = null; private volatile static MAcctSchema s_AcctSchema = null;
/** MWindow for AccountCombination */ /** MWindow for AccountCombination */
private GridWindow m_mWindow = null; private GridWindow m_mWindow = null;
/** MTab for AccountCombination */ /** MTab for AccountCombination */

View File

@ -43,7 +43,7 @@ import org.compiere.util.WebEnv;
public class StoreFilter implements javax.servlet.Filter public class StoreFilter implements javax.servlet.Filter
{ {
/** Logging */ /** Logging */
private static CLogger log = null; private volatile static CLogger log = null;
/** /**
* Init * Init

View File

@ -164,7 +164,7 @@ public class DB_Oracle implements AdempiereDatabase
* @return Driver * @return Driver
* @throws SQLException * @throws SQLException
*/ */
public Driver getDriver() throws SQLException public synchronized Driver getDriver() throws SQLException
{ {
if (s_driver == null) if (s_driver == null)
{ {

View File

@ -45,7 +45,7 @@ import fitnesse.fixtures.TableFixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class AssertRecord extends TableFixture { public class AssertRecord extends TableFixture {
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
@Override @Override
protected void doStaticTable(int rows) { protected void doStaticTable(int rows) {

View File

@ -36,7 +36,7 @@ import fitnesse.fixtures.TableFixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class AssertVariable extends TableFixture { public class AssertVariable extends TableFixture {
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
@Override @Override
protected void doStaticTable(int rows) { protected void doStaticTable(int rows) {

View File

@ -44,7 +44,7 @@ import fitnesse.fixtures.TableFixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class CreateRecord extends TableFixture { public class CreateRecord extends TableFixture {
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
@Override @Override
protected void doStaticTable(int rows) { protected void doStaticTable(int rows) {

View File

@ -39,7 +39,7 @@ import fitnesse.fixtures.TableFixture;
*/ */
public class Login extends TableFixture { public class Login extends TableFixture {
private static final String LANGUAGE_EN_US = "en_US"; private static final String LANGUAGE_EN_US = "en_US";
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
private String m_user; private String m_user;
private String m_password; private String m_password;
private String m_language; private String m_language;

View File

@ -45,7 +45,7 @@ import fitnesse.fixtures.TableFixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class ReadRecord extends TableFixture { public class ReadRecord extends TableFixture {
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
@Override @Override
protected void doStaticTable(int rows) { protected void doStaticTable(int rows) {

View File

@ -58,7 +58,7 @@ import fitnesse.fixtures.TableFixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class RunProcess extends TableFixture { public class RunProcess extends TableFixture {
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
private static CLogger log = CLogger.getCLogger(RunProcess.class); private static CLogger log = CLogger.getCLogger(RunProcess.class);

View File

@ -43,7 +43,7 @@ import fitnesse.fixtures.TableFixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class SetDocAction extends TableFixture { public class SetDocAction extends TableFixture {
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
@Override @Override
protected void doStaticTable(int rows) { protected void doStaticTable(int rows) {

View File

@ -38,7 +38,7 @@ import fitnesse.fixtures.TableFixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class SetVariable extends TableFixture { public class SetVariable extends TableFixture {
private static Instance adempiereInstance = null; private volatile static Instance adempiereInstance = null;
@Override @Override
protected void doStaticTable(int rows) { protected void doStaticTable(int rows) {

View File

@ -32,7 +32,7 @@ package org.idempiere.fitnesse.fixture;
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
*/ */
public class Static_iDempiereInstance { public class Static_iDempiereInstance {
private static Instance adempiereInstance; private volatile static Instance adempiereInstance;
public static Instance getInstance() { public static Instance getInstance() {
if (adempiereInstance == null) { if (adempiereInstance == null) {

View File

@ -39,7 +39,7 @@ public class Activator implements BundleActivator {
return context; return context;
} }
private static HazelcastInstance hazelcastInstance; private volatile static HazelcastInstance hazelcastInstance;
private static AtomicReference<Future<?>> futureRef = new AtomicReference<Future<?>>(); private static AtomicReference<Future<?>> futureRef = new AtomicReference<Future<?>>();
/* /*