harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Fursov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-496) Thread unsafe lazy instantiation of static field : javax.crypto
Date Tue, 23 May 2006 11:57:29 GMT
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);)


 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

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message