Issue Details (XML | Word | Printable)

Key: OSGI-522
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Costin Leau
Reporter: Björn Voß
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring OSGi

AbstractOsgiPlatform.getConfigurationProperties always overrides properties

Created: 03/Jun/08 04:12 AM   Updated: 26/Jun/08 05:40 AM
Component/s: TESTING
Affects Version/s: 1.1 M2
Fix Version/s: 1.1 RC1

Time Tracking:
Not Specified

Issue Links:
Related
 


 Description  « Hide
public Properties getConfigurationProperties() {
// local properties
configurationProperties.putAll(getPlatformProperties());
// system properties
configurationProperties.putAll(System.getProperties());
return configurationProperties;
}

always overrides the properties, so you can't change platform properties by overriding createPlatfrom in your tests. For example I want the osgi.instance.area under target/eclipse_conf so it is automatically deleted by 'mvn clean'

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Costin Leau added a comment - 05/Jun/08 02:40 AM
Björn, I've inverted the statements so now the local properties override the system ones. I've committed a fix - it would be great if you could try the latest build and report back.
Cheers,

Björn Voß added a comment - 05/Jun/08 04:53 AM
Hello Costin,
I'm sorry I didn't make my point clear enough. The change you made, fixes my current problem but I still think I could be confusing in some ways.

If I override createPlatform in my test like this
@Override
protected OsgiPlatform createPlatform() {
final OsgiPlatform platform = super.createPlatform();
final Properties props = platform.getConfigurationProperties();
props.setProperty("some.prop", "valueA");
props.setProperty("other.prop", "valueB");
return platform;
}
then I would expect these properties to be set in platform. But in the current implementation I have to think about system properties and - the more confusing part in my eyes - properties from getPlatformProperties(), which I can only find in the source code.

I'm now aware of this behaviour but other users, especially new users may not. So I would suggest something like:
public Properties getConfigurationProperties() {
if (configurationProperties == null) {
  configurationProperties = new Properties();
  // local properties
  configurationProperties.putAll(getPlatformProperties());
  // system properties
  configurationProperties.putAll(System.getProperties());
}
return configurationProperties;
}
so the properties would be initiated with the default and system values but after that it's up to the user to change them.

I hope I make my point clear and you understand what I mean.

Cheers Björn

Costin Leau added a comment - 06/Jun/08 09:02 AM
Björn, you are right - the getPlatformProperties was not meant to be protected - only package protected. I've changed the implementation and marked the method as deprecated - after RC1 I plan to change it to package protected.
Let me know if this works for you now (seems to do so in the tests).

Björn Voß added a comment - 09/Jun/08 03:44 AM
Hello Costin

The configuration problem of the testplatform has gone, when I use 1.1.0-rc1-SNAPSHOT, but now I get this error during the startup of my test bundles

2008-06-09 10:32:29,103 ERROR [SpringOsgiExtenderThread-6] (ServiceDynamicInterc
eptor ) - Event org.springframework.osgi.service.importer.event.OsgiServic
eDependencySatisfiedEvent[source=org.springframework.osgi.service.importer.suppo
rt.OsgiServiceProxyFactoryBean@1bfa303] not published as the publisher is not in
itialized - usually this is caused by eager initialization of the importers by p
ost processing
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c
all 'refresh' before multicasting events via the context: org.springframework.os
gi.context.support.OsgiBundleXmlApplicationContext@95ef17: display name [OsgiBun
dleXmlApplicationContext(bundle=ag.pinguin.app-inkasso-service, config=osgibundl
e:/META-INF/spring/*.xml)]; startup date [Mon Jun 09 10:32:28 CEST 2008]; root o
f context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getApp
licationEventMulticaster(AbstractApplicationContext.java:288)
        at org.springframework.context.support.AbstractApplicationContext.publis
hEvent(AbstractApplicationContext.java:275)
        at org.springframework.osgi.service.importer.support.internal.aop.Servic
eDynamicInterceptor.publishEvent(ServiceDynamicInterceptor.java:423)
        at org.springframework.osgi.service.importer.support.internal.aop.Servic
eDynamicInterceptor.access$200(ServiceDynamicInterceptor.java:64)
        at org.springframework.osgi.service.importer.support.internal.aop.Servic
eDynamicInterceptor$EventSenderRetryTemplate.execute(ServiceDynamicInterceptor.j
ava:101)
        at org.springframework.osgi.service.importer.support.internal.aop.Servic
eDynamicInterceptor.lookupService(ServiceDynamicInterceptor.java:409)
        at org.springframework.osgi.service.importer.support.internal.aop.Servic
eDynamicInterceptor.getTarget(ServiceDynamicInterceptor.java:391)
        at org.springframework.osgi.service.importer.support.internal.aop.Servic
eDynamicInterceptor.afterPropertiesSet(ServiceDynamicInterceptor.java:455)
        at org.springframework.osgi.service.importer.support.OsgiServiceProxyFac
toryBean.createProxy(OsgiServiceProxyFactoryBean.java:173)
        at org.springframework.osgi.service.importer.support.AbstractOsgiService
ImportFactoryBean.getObject(AbstractOsgiServiceImportFactoryBean.java:101)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$
1.run(FactoryBeanRegistrySupport.java:121)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.
doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.
getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:91)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getObje
ctForBeanInstance(AbstractBeanFactory.java:1285)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:275)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:164)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveReference(BeanDefinitionValueResolver.java:269)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1244)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveInnerBean(BeanDefinitionValueResolver.java:219)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveValueIfNecessary(BeanDefinitionValueResolver.java:122)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1244)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:264)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:220)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:261)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:164)
        at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetriev
alHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:87)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyC
reator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:98)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyC
reator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:84)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyC
reator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.
wrapIfNecessary(AbstractAutoProxyCreator.java:345)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.
postProcessAfterInitialization(AbstractAutoProxyCreator.java:309)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFa
ctory.java:361)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1342)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:264)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:220)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:261)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:164)
        at org.springframework.osgi.extender.internal.dependencies.startup.Manda
toryImporterDependencyFactory.getServiceDependencies(MandatoryImporterDependency
Factory.java:54)
        at org.springframework.osgi.extender.internal.dependencies.startup.Depen
dencyServiceManager.findServiceDependencies(DependencyServiceManager.java:214)
        at org.springframework.osgi.extender.internal.dependencies.startup.Depen
dencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContex
tExecutor.java:249)
        at org.springframework.osgi.extender.internal.dependencies.startup.Depen
dencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContext
Executor.java:173)
        at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp
plicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:136)
        at org.springframework.osgi.extender.internal.activator.ContextLoaderLis
tener$2.run(ContextLoaderListener.java:749)
        at java.lang.Thread.run(Thread.java:595)


If I use 1.1.0-m2 everything works fine.

I don't think it has something to do with this issue, but I want to ask for any changes in the behaviour of the test framework from 1.1.0-m2 to 1.1.0-rc1-SNAPSHOT

Costin Leau added a comment - 09/Jun/08 03:49 AM
There aren't any connections - please open a separate issue. Make sure first that you are using the latest snapshot of both Spring-DM 1.1 RC1 and Spring 2.5.5. The problem, in your case, is caused by too early initialization of the importers during dependency detection. Since the importer trigger an event before waiting and the application context is not initialized, you'll end up with that exception.
The latest snapshot throws a warning/error message instead of throwing the exception - check out the logs and let me know if you still encounter the problem.