Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQ] Prevent log messages to be built in case they are not logged #44510

Open
2 tasks done
ecnabogs opened this issue Mar 5, 2025 · 1 comment
Open
2 tasks done
Assignees
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

Comments

@ecnabogs
Copy link

ecnabogs commented Mar 5, 2025

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.

        keyVaultCertificates = new KeyVaultCertificates(refreshInterval, keyVaultUri, tenantId, clientId, clientSecret,
            managedIdentity, disableChallengeResourceVerification);
        LOGGER.log(FINE, String.format("Loaded Key Vault certificates: %s.", keyVaultCertificates.getAliases()));

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

  • Description Added
  • Expected solution specified
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 5, 2025
@joshfree joshfree added azure-spring All azure-spring related issues azure-spring-jca labels Mar 5, 2025
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 5, 2025
@joshfree
Copy link
Member

joshfree commented Mar 5, 2025

Thanks for taking the time to file this issue, @ecnabogs. @saragluna will follow up shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
Status: Todo
Development

No branches or pull requests

3 participants