You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Fursov (JIRA)" <ji...@apache.org> on 2006/05/23 13:57:29 UTC
[jira] Created: (HARMONY-496) Thread unsafe lazy instantiation of
static field : javax.crypto
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
[jira] Commented: (HARMONY-496) Thread unsafe lazy instantiation of
static field : javax.crypto
Posted by "Mikhail Loenko (JIRA)" <ji...@apache.org>.
[ 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
[jira] Closed: (HARMONY-496) Thread unsafe lazy instantiation of
static field : javax.crypto
Posted by "Mikhail Loenko (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HARMONY-496?page=all ]
Mikhail Loenko closed HARMONY-496.
----------------------------------
Resolution: Invalid
Assignee: Mikhail Loenko
in both cases the spec does not require us to be thread-safe
> Thread unsafe lazy instantiation of static field : javax.crypto
> ---------------------------------------------------------------
>
> Key: HARMONY-496
> URL: http://issues.apache.org/jira/browse/HARMONY-496
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Mikhail Fursov
> Assigned To: Mikhail Loenko
> 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