RFR: 8273977: Reduce unnecessary BadPaddingExceptions in RSAPadding

Lari Hotari duke at openjdk.java.net
Wed Nov 3 19:03:23 UTC 2021


### Motivation

When profiling an application that uses JWT token authentication, it was noticed that a high number of `javax.crypto.BadPaddingException`s were created. When investigating the code in RSAPadding, one can see that BadPaddingException is created in all cases, also on the success path:
https://github.com/openjdk/jdk/blob/dc7f452acbe3afa5aa6e31d316bd5e669c86d6f6/src/java.base/share/classes/sun/security/rsa/RSAPadding.java#L369-L375

### Modifications

Inline the unnecessary local variable to prevent creating the exception on the success path.

-------------

Commit messages:
 - Reduce unnecessary BadPaddingExceptions that are created in success path

Changes: https://git.openjdk.java.net/jdk/pull/5581/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5581&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8273977
  Stats: 6 lines in 1 file changed: 0 ins; 4 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5581.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5581/head:pull/5581

PR: https://git.openjdk.java.net/jdk/pull/5581



More information about the security-dev mailing list