8358316: PKCS8Key.getEncoded() can throw NPE after JDK-8298420

Reviewed-by: ascarpino
This commit is contained in:
Aleksey Shipilev 2025-06-03 08:14:05 +00:00
parent be923a8b72
commit cff75eb606

View File

@ -256,7 +256,8 @@ public class PKCS8Key implements PrivateKey, InternalPrivateKey {
* or {@code null} if an encoding error occurs.
*/
public byte[] getEncoded() {
return getEncodedInternal().clone();
byte[] b = getEncodedInternal();
return (b != null) ? b.clone() : null;
}
/**