harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Loenko (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-496) Thread unsafe lazy instantiation of static field : javax.crypto
Date Fri, 26 May 2006 05:15:30 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-496?page=comments#action_12413365 ] 

Mikhail Loenko commented on HARMONY-496:
----------------------------------------

Cipher part in theory is thread-unsafe but in the given case it's OK since it does not matter
which secure random instance is passed to the init. I'll add a comment to the source

> Thread unsafe lazy instantiation of static field : javax.crypto
> ---------------------------------------------------------------
>
>          Key: HARMONY-496
>          URL: http://issues.apache.org/jira/browse/HARMONY-496
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Mikhail Fursov
>     Priority: Minor

>
> In classes 
> javax.crypto.Cypher :
> public final void init(int opmode, Key key) throws InvalidKeyException {
>         if (sec_rand == null) {
>             sec_rand = new SecureRandom();
>         }
>         init(opmode, key, sec_rand);)
> and 
> org.apache.harmony.beans.ArrayPersistenceDelegate:
>  public static PersistenceDelegate getInstance() {
>         if(pd == null) {
>             pd = new ArrayPersistenceDelegate();
>         }
>         return pd;
>     }
> static field initialization is not guarded by synchronization block. So in multithreaded
environment the behaviour of these methods may be wrong.
> I propose to replace lazy instantiation of the 'sec_rand'  variable in javax.crypto.Cypher
with instantiation during class initializer call
> and to use DCL (double checking locking) and synchronization into org.apache.harmony.beans.ArrayPersistenceDelegate
class.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message