Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330769

Summary: DataSourceTracker is using bundle context of the service provider bundle to get the service
Product: [RT] Gemini.JPA Reporter: Sahoo <sanjeeb.sahoo>
Component: CoreAssignee: Michael Keith <michael.keith>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.0.0   
Target Milestone: 1.0.0 M4   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Sahoo CLA 2010-11-22 03:12:01 EST
I see the following code in DataSourceTracker.java:
    public Object addingService(ServiceReference ref) {

        return ref.getBundle().getBundleContext().getService(ref);

    }


ServiceReference.getBundle() returns the bundle that registered the service referenced by this service reference. Should the above code not be using its own bundle context instead? So, instead of 
ref.getBundle(), 
use
BundleReference.class.cast(getClass().getClassLoader()).getBundle().
Comment 1 Michael Keith CLA 2010-12-03 12:47:54 EST
The tracker is not used to obtain services - this line was just filled in to return something resembling the service. However, it never hurts to make it correct just in case someone down the road decide they now want to use the tracker to get the service ;-)