-
Enhancement
-
Resolution: Fixed
-
P4
-
25
-
b26
SonarCloud complains we are using the String.replaceAll() method that creates Pattern internally every time:
/**
* Decodes a PEM-encoded block.
*
* @param input the input string, according to RFC 1421, can only contain
* characters in the base-64 alphabet and whitespaces.
* @return the decoded bytes
*/
public static byte[] decode(String input) {
byte[] src = input.replaceAll("\\s+", "").
getBytes(StandardCharsets.ISO_8859_1);
return Base64.getDecoder().decode(src);
}
We already have cached Patterns for other cases, we should do the same here.
/**
* Decodes a PEM-encoded block.
*
* @param input the input string, according to RFC 1421, can only contain
* characters in the base-64 alphabet and whitespaces.
* @return the decoded bytes
*/
public static byte[] decode(String input) {
byte[] src = input.replaceAll("\\s+", "").
getBytes(StandardCharsets.ISO_8859_1);
return Base64.getDecoder().decode(src);
}
We already have cached Patterns for other cases, we should do the same here.
- caused by
-
JDK-8298420 Implement JEP 470: PEM Encodings of Cryptographic Objects (Preview)
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk/6f783e5f
-
Review(master) openjdk/jdk/25583