RFR: 8274050: Unnecessary Vector usage in javax.crypto

Valerie Peng valeriep at openjdk.java.net
Tue Sep 28 19:16:46 UTC 2021


On Thu, 26 Aug 2021 06:19:49 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

> In [JDK-8268873](https://bugs.openjdk.java.net/browse/JDK-8268873) I missed a few places, where Vector could be replaced with ArrayList.
> Usage of thread-safe collection `Vector` is unnecessary. It's recommended to use `ArrayList` if a thread-safe implementation is not needed.

Just some nit. Rest looks fine. Thanks.

src/java.base/share/classes/javax/crypto/CryptoPermissions.java line 347:

> 345: 
> 346:         CryptoPermission[] ret = permList.toArray(new CryptoPermission[0]);
> 347:         return ret;

nit: no need for local variable, can just do return permList.toArray(new CryptoPermission[0]) call. Same goes for line 390-391.

src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java line 491:

> 489: 
> 490:         CryptoPermission[] ret = result.toArray(new CryptoPermission[0]);
> 491:         return ret;

Same nit, no need for local variable here.

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

PR: https://git.openjdk.java.net/jdk/pull/5261



More information about the security-dev mailing list