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

Bug 357484

Summary: Adding an aspect to a blueprint reference works 50% of the time
Product: [RT] Gemini.Blueprint Reporter: Morten Knudsen <mkn>
Component: CoreAssignee: Project Inbox <gemini.blueprint-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: glyn.normington, olaf
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Morten Knudsen CLA 2011-09-13 09:07:42 EDT
Build Identifier: 

I have defined an osgi reference to a javax.sql.DataSource with blueprint 1.0GA, and added an aspect with a aspectj-style pointcut "execution(* javax.sql.DataSource.getConnection(..))". The strange thing is that the aspect is only applied about 70% of the times the application starts (the bean is created every time, of course). In the other cases, it's just ignored. The same thing happens with Spring DM 1.2.1, which I used at first. 

Reproducible: Sometimes

Steps to Reproduce:
1. Create a reference to a data source
2. Create an aspect in the same context with pointcut "execution(* javax.sql.DataSource.getConnection(..))"
3. Trigger getConnection() and see it the advice is active
Comment 1 Morten Knudsen CLA 2011-09-28 08:53:57 EDT
I have some more info: 
In the cases where the aspect works, the data source bean classloader is BundleDelegatingClassLoader, while in the cases where it doesn't work, it's org.eclipse.gemini.blueprint.context.support.internal.classloader.ChainedClassLoader
I found this out by creating a bean: 
public class DataSourceChecker {

	private Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	public DataSourceChecker(DataSource dataSource) {
		log.info("DataSource classloader = " + dataSource.getClass().getClassLoader());
	}
}
Comment 2 Glyn Normington CLA 2013-01-28 10:21:14 EST
(In reply to comment #1)
> I have some more info: 
> In the cases where the aspect works, the data source bean classloader is
> BundleDelegatingClassLoader, while in the cases where it doesn't work, it's
> org.eclipse.gemini.blueprint.context.support.internal.classloader.
> ChainedClassLoader
> I found this out by creating a bean: 
> public class DataSourceChecker {
> 
> 	private Logger log = LoggerFactory.getLogger(getClass());
> 
> 	@Autowired
> 	public DataSourceChecker(DataSource dataSource) {
> 		log.info("DataSource classloader = " +
> dataSource.getClass().getClassLoader());
> 	}
> }

That's weird because it means that sometimes ChainedClassLoader is supposedly the defining class loader of DataSource.

I'm afraid I can't invest the time to reproduce this problem and look into it. If it's still of interest to you, you may care to attach a sample project which reproduces the problem plus steps to reproduce the problem. That might encourage someone else to invest the time. Sorry!
Comment 3 Olaf Otto CLA 2016-04-28 08:15:17 EDT
There has not been any activity on this ticket since a long time. Also, this behavior needs to be re-tested with the recent most release. I'll close this as won't fix. To be re-opened if the requirement arises.