You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Pierre De Rop (JIRA)" <ji...@apache.org> on 2016/11/10 15:38:58 UTC
[jira] [Assigned] (FELIX-5405) Do not have
org.apache.felix.dm.Logger invoke toString() of message parameters when
enabled log level is not high enough
[ https://issues.apache.org/jira/browse/FELIX-5405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pierre De Rop reassigned FELIX-5405:
------------------------------------
Assignee: Pierre De Rop
Thanks Dobias, I will look into this quickly.
> Do not have org.apache.felix.dm.Logger invoke toString() of message parameters when enabled log level is not high enough
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: FELIX-5405
> URL: https://issues.apache.org/jira/browse/FELIX-5405
> Project: Felix
> Issue Type: Improvement
> Components: Dependency Manager
> Affects Versions: org.apache.felix.dependencymanager-r8
> Reporter: Dobias van Buuren
> Assignee: Pierre De Rop
>
> My attention was drawn to the following code block when I encountered a NPE at runtime. In this situation, the Dependency manager wanted to debug log some class instance, but the class instances' toString() implementation (from a 3rd party in this case) raised a NPE. While it is arguable why the toString() implementation was not that robust, it triggered a problem with the logging in the DM.
> {code}
> public void debug(String format, Object... params) {
> log(LogService.LOG_DEBUG, String.format(format, params));
> }
> {code}
> In the above code block you can see that the String.format(...) is performed ALWAYS, without checking for the log level being debug.
> I suggest deferring the String.format() into the log() method, and only performing the formatting if we need to write the message to the log. (PERFORMANCE)
> Also it might be wise to perform the String.format() operation in a try catch block to prevent exceptions during logging that occur when String parameters need to be created using Object.toString(). (ROBUSTNESS)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)