On Thu, 21 May 2026 10:20:06 GMT, Krushna948 <[email protected]> wrote:
>> Anthony Scarpino has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> comments
>
> src/java.base/share/classes/java/security/PEMDecoder.java line 326:
>
>> 324: * @param is {@code InputStream} containing PEM data
>> 325: * @return a {@code BinaryEncodable}
>> 326: * @throws IOException if an I/O error occurs or PEM syntax is
>> invalid
>
> “PEMDecoder.decode(InputStream) and decode(InputStream, Class): clarify which
> errors are reported as IllegalArgumentException vs. IOException when PEM
> syntax is invalid, since both phrases (‘decoding fails’ and ‘PEM syntax is
> invalid’) currently overlap.”
>
> For example
>
> @TestCase
> @TestedStatement(source = "decode(InputStream, Class)", value =
> "Throws: IOException - if an I/O error occurs or PEM syntax is
> invalid")
> public void decodeWithType_InputStream_invalidSyntax_IOEx() throws
> IOException {
> String invalidSyntax =
> "-----BEGIN PUBLIC KEY-----\n" +
> "!!!NOT-BASE64!!!\n" +
> "-----END PUBLIC KEY-----\n";
> try (ByteArrayInputStream bais = new
> ByteArrayInputStream(invalidSyntax.getBytes(ISO_8859_1))) {
> Assert.assertThrows(() -> PEMDecoder.of().decode(bais,
> PublicKey.class), IOException.class);
> }
> }
Legacy PEM, such as encrypted RSA PRIVATE KEY, has non-Base64 characters and is
valid. PEM syntax is the header and footer, not the content which is used
during decoding or stored in a PEM.class. I don't see this as overlapping.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29640#discussion_r3281828089