Skip to content

Commit cd3a607

Browse files
blperez01wangweij
authored andcommittedMay 2, 2024
8328864: NullPointerException in sun.security.jca.ProviderList.getService()
Reviewed-by: weijun
1 parent 73cdc9a commit cd3a607

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed
 

‎src/java.base/share/classes/sun/security/jca/ProviderList.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -369,17 +369,19 @@ public Service getService(String type, String name) {
369369
int i;
370370

371371
// Preferred provider list
372-
if (preferredPropList != null &&
373-
(pList = preferredPropList.getAll(type, name)) != null) {
372+
if (preferredPropList != null) {
373+
pList = preferredPropList.getAll(type, name);
374374
for (i = 0; i < pList.size(); i++) {
375375
Provider p = getProvider(pList.get(i).provider);
376+
if (p == null) {
377+
continue;
378+
}
376379
Service s = p.getService(type, name);
377380
if (s != null) {
378381
return s;
379382
}
380383
}
381384
}
382-
383385
for (i = 0; i < configs.length; i++) {
384386
Provider p = getProvider(i);
385387
Service s = p.getService(type, name);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import java.security.*;
25+
26+
/**
27+
* @test
28+
* @bug 8328864
29+
* @summary Test that ProviderList.getService checks configs when
30+
* ProviderList.getProvider fails for preferred providers.
31+
* @run main/othervm
32+
* -Djava.security.properties=${test.src}/app-security.properties NullPreferredList
33+
*/
34+
35+
public class NullPreferredList {
36+
37+
public static void main(final String[] args) throws Exception {
38+
final KeyStore ks = KeyStore.getInstance("PKCS12");
39+
System.out.println("Got keystore " + ks);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jdk.security.provider.preferred=KeyStore.PKCS12:NonExistingProvider

0 commit comments

Comments
 (0)