db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-4723) Using an instance lock to protect static shared data in EmbedPooledConnection
Date Wed, 28 Jul 2010 12:57:18 GMT

     [ https://issues.apache.org/jira/browse/DERBY-4723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kristian Waagan updated DERBY-4723:
-----------------------------------

    Attachment: derby-4723-1a-remove_code.diff

Attached patch 1a, which removes the code using incorrect synchronization.


> Using an instance lock to protect static shared data in EmbedPooledConnection
> -----------------------------------------------------------------------------
>
>                 Key: DERBY-4723
>                 URL: https://issues.apache.org/jira/browse/DERBY-4723
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.5.1.1
>            Reporter: Wendy Feng
>            Priority: Minor
>         Attachments: derby-4723-1a-remove_code.diff
>
>   Original Estimate: 0.17h
>  Remaining Estimate: 0.17h
>
> EmbedPooledConnection has the unsafe synchronization as follow.
>  
> private static int idCounter = 0;
> private synchronized int nextId()
>     {
>         return idCounter++;
>     }
> idCounter is a static shared data, and it is not proper to use a instance lock to protect
it, especially when two instance of the class are created.
> it would be more safer to write this instead:
> private static synchronized int nextId()
>     {
>         return idCounter++;
>     }

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


Mime
View raw message