You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Edward Ribeiro (JIRA)" <ji...@apache.org> on 2009/06/14 16:50:07 UTC

[jira] Created: (CASSANDRA-228) Improve the readability of the DBManager.instance() method

Improve the readability of the DBManager.instance() method
----------------------------------------------------------

                 Key: CASSANDRA-228
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-228
             Project: Cassandra
          Issue Type: Improvement
            Reporter: Edward Ribeiro


The DBManager class implements the singleton pattern using a Lock object, but it could replace the Lock object by declaring the instance() method as synchronized. Therefore, it avoids the race condition (as with Lock), but improves the readability and reduces the size of the method. Below is the new version of the method:

	public static synchronized DBManager instance() throws IOException
	{
		if (dbMgr_ == null)
			dbMgr_ = new DBManager();
		return dbMgr_;
	}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CASSANDRA-228) Improve the readability of the DBManager.instance() method

Posted by "Edward Ribeiro (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CASSANDRA-228?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Edward Ribeiro updated CASSANDRA-228:
-------------------------------------

    Attachment: CASSANDRA-228.patch

The patch.

> Improve the readability of the DBManager.instance() method
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-228
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-228
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Edward Ribeiro
>         Attachments: CASSANDRA-228.patch
>
>
> The DBManager class implements the singleton pattern using a Lock object, but it could replace the Lock object by declaring the instance() method as synchronized. Therefore, it avoids the race condition (as with Lock), but improves the readability and reduces the size of the method. Below is the new version of the method:
> 	public static synchronized DBManager instance() throws IOException
> 	{
> 		if (dbMgr_ == null)
> 			dbMgr_ = new DBManager();
> 		return dbMgr_;
> 	}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CASSANDRA-228) Improve the readability of the DBManager.instance() method

Posted by "Michael Greene (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CASSANDRA-228?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Greene updated CASSANDRA-228:
-------------------------------------

    Component/s: Core

> Improve the readability of the DBManager.instance() method
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-228
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-228
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Edward Ribeiro
>            Assignee: Edward Ribeiro
>             Fix For: 0.4
>
>         Attachments: CASSANDRA-228.patch
>
>
> The DBManager class implements the singleton pattern using a Lock object, but it could replace the Lock object by declaring the instance() method as synchronized. Therefore, it avoids the race condition (as with Lock), but improves the readability and reduces the size of the method. Below is the new version of the method:
> 	public static synchronized DBManager instance() throws IOException
> 	{
> 		if (dbMgr_ == null)
> 			dbMgr_ = new DBManager();
> 		return dbMgr_;
> 	}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CASSANDRA-228) Improve the readability of the DBManager.instance() method

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12720100#action_12720100 ] 

Hudson commented on CASSANDRA-228:
----------------------------------

Integrated in Cassandra #110 (See [http://hudson.zones.apache.org/hudson/job/Cassandra/110/])
    switch singleton implementation from double-checked-locking to synchronized (code is not performance-sensitive).  patch by Edward Ribeiro; reviewed by jbellis for 


> Improve the readability of the DBManager.instance() method
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-228
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-228
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Edward Ribeiro
>            Assignee: Edward Ribeiro
>         Attachments: CASSANDRA-228.patch
>
>
> The DBManager class implements the singleton pattern using a Lock object, but it could replace the Lock object by declaring the instance() method as synchronized. Therefore, it avoids the race condition (as with Lock), but improves the readability and reduces the size of the method. Below is the new version of the method:
> 	public static synchronized DBManager instance() throws IOException
> 	{
> 		if (dbMgr_ == null)
> 			dbMgr_ = new DBManager();
> 		return dbMgr_;
> 	}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CASSANDRA-228) Improve the readability of the DBManager.instance() method

Posted by "Jonathan Ellis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CASSANDRA-228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12719280#action_12719280 ] 

Jonathan Ellis commented on CASSANDRA-228:
------------------------------------------

Can you submit patches with svn diff, please?

> Improve the readability of the DBManager.instance() method
> ----------------------------------------------------------
>
>                 Key: CASSANDRA-228
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-228
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Edward Ribeiro
>
> The DBManager class implements the singleton pattern using a Lock object, but it could replace the Lock object by declaring the instance() method as synchronized. Therefore, it avoids the race condition (as with Lock), but improves the readability and reduces the size of the method. Below is the new version of the method:
> 	public static synchronized DBManager instance() throws IOException
> 	{
> 		if (dbMgr_ == null)
> 			dbMgr_ = new DBManager();
> 		return dbMgr_;
> 	}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.