RFR: 8331008: Implement JEP 478: Key Derivation Function API (Preview) [v10]

Valerie Peng valeriep at openjdk.org
Tue Sep 3 20:19:34 UTC 2024


On Fri, 30 Aug 2024 23:13:04 GMT, Kevin Driver <kdriver at openjdk.org> wrote:

>> src/java.base/share/classes/javax/crypto/KDF.java line 121:
>> 
>>> 119:     private Iterator<Service> serviceIterator;
>>> 120: 
>>> 121:     private final Object lock;
>> 
>> Why are you using an `Object` as a lock instead of something like `ReentrantLock`?  I realize older implementations used this style, but does this need to be mimicked?
>
> @valeriepeng:
> 
> I did some research. Based upon what I have seen, no `volatile` keyword is required here. This is also consistent with the `Cipher` API, for example.
> 
> @ascarpino: 
> 
> I looked up `ReentrantLock`s, and I’m not sure those make sense for the use-case. A simple mutex lock should suffice, since we will not be spinning for long. In addition, as mentioned above, we are consistent with the other JCE/JCA classes by using this paradigm.

Well, I am not so sure, I've sent you pointers separately regarding lazy initialization and the relevant concurrency pointers.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20301#discussion_r1742635232


More information about the security-dev mailing list