8343194: Avoid redundant Hashtable.containsKey call in CodeSource.readObject

Reviewed-by: mullan
This commit is contained in:
Andrey Turbanov 2024-11-01 11:47:00 +00:00
parent 4a70c83bd0
commit f77a5144a1

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -556,7 +556,6 @@ public class CodeSource implements java.io.Serializable {
private void readObject(java.io.ObjectInputStream ois)
throws IOException, ClassNotFoundException
{
CertificateFactory cf;
Hashtable<String, CertificateFactory> cfs = null;
List<java.security.cert.Certificate> certList = null;
@ -577,10 +576,8 @@ public class CodeSource implements java.io.Serializable {
// read the certificate type, and instantiate a certificate
// factory of that type (reuse existing factory if possible)
String certType = ois.readUTF();
if (cfs.containsKey(certType)) {
// reuse certificate factory
cf = cfs.get(certType);
} else {
CertificateFactory cf = cfs.get(certType);
if (cf == null) {
// create new certificate factory
try {
cf = CertificateFactory.getInstance(certType);