[
https://issues.apache.org/jira/browse/FELIX-6281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17119888#comment-17119888
]
Tom Watson commented on FELIX-6281:
-----------------------------------
I discovered this issue while investigating a fix for FELIX-6274 where I want
to modify SCR to use the getLogger(Bundle ...) method. But the testcase will
fail if the felix LoggerFactory implementation is used because I get a cast
exception.
> Potential class space issues for getLogger(Bundle ...)
> ------------------------------------------------------
>
> Key: FELIX-6281
> URL: https://issues.apache.org/jira/browse/FELIX-6281
> Project: Felix
> Issue Type: Improvement
> Components: Log Service
> Affects Versions: log-1.2.2
> Reporter: Tom Watson
> Priority: Major
>
> The method org.osgi.service.log.LoggerFactory.getLogger(Bundle, String,
> Class<L>) can get a cast exception on the return from
> org.apache.felix.log.LogServiceImpl.getLogService(Bundle) if the specified
> bundle is wired to another version of the org.osgi.service.log package and
> there is another LogService registered using that version of the package.
>
> There are a few other issues with the approach of using the specified
> bundle's context.
> * The bundle may not have a valid BundleContext if it is not
> STARTING/STOPPING/ACTIVE
> * If there is no LogService registered with the other package then there
> will be no available ServiceReference
> * The state check for RESOLVED || ACTIVE is problematic because it omits
> STARTING/STOPPING but it also lets it try to get a context for a RESOLVED
> bundle which will cause an NPE
>
> Instead the method should allow you to get a logger as long as the bundle is
> not UNINSTALLED in my opinion.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)