[FEATURE REQ] Prevent log messages to be built in case they are not logged #44510
Labels
azure-spring
All azure-spring related issues
azure-spring-jca
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Is your feature request related to a problem? Please describe.
I cannot manage to initialize a KeyVaultKeyStore because there are unconditional logs that trigger the loading of certificates which in my case fail. I understand that the real problem is the loading issue however, it is not acceptable that log method calls lead to that eager loading, especially when the respective log level is not enable.
As you may have understood, my request is related to the library Azure KeyVault JCA (com.azure:azure-security-keyvault-jca:2.10.0) but might also apply to others.
Describe the solution you'd like
You should use the java.util.logging.Logger.log methods that take a Supplier argument to provide the log message and supply a lambda. It is available since Java 8 ! It is really a best practice to build log messages only when necessary since it can have a really bad impact on performance. Notice also that instead of passing the log level, you can also call the respective level-associated method directly (fine(...) for Level.FINE).
Describe alternatives you've considered
Another technique is to check that the log level is enable before logging but it is really more verbose and makes the code less readable.
Additional context
Here is an example of such a logging call in
KeyVaultKeyStore
that eagerly loads the KeyVault certificates.Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: