Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0033077 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [Openbravo ERP] A. Platform | minor | always | 2016-05-30 13:58 | 2016-08-11 18:40 | |||
Reporter | shuehner | View Status | public | |||||
Assigned To | alostale | |||||||
Priority | urgent | Resolution | fixed | Fixed in Version | 3.0PR16Q4 | |||
Status | closed | Fix in branch | Fixed in SCM revision | e05fce66f7ed | ||||
Projection | none | ETA | none | Target Version | ||||
OS | Any | Database | Any | Java version | ||||
OS Version | Database version | Ant version | ||||||
Product Version | SCM revision | |||||||
Merge Request Status | ||||||||
Review Assigned To | caristu | |||||||
OBNetwork customer | No | |||||||
Web browser | ||||||||
Modules | Core | |||||||
Support ticket | ||||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0033077: ImportEntryManager constructor called twice even if ApplicationScoped | |||||||
Description | The constructor of ImportEntryManager is called two times. However it is marked as ApplicationScoped + assumes single instance as storing itself in static variable (+getInstace()). So calling constructor twice seems wrong. Note: Impact of this is unclear Note: the 2 instanciones come from the 2 contextListeners which instantiate (via weld) the class. Stacktrace (produced with the diff attached): 10473 [main] INFO org.openbravo.service.importprocess.ImportEntryManager - Calling ImportEntryManager constructor java.lang.Throwable at org.openbravo.service.importprocess.ImportEntryManager.<init>(ImportEntryManager.java:176) at org.openbravo.service.importprocess.ImportEntryManager$Proxy$_$$_WeldClientProxy.<init>(ImportEntryManager$Proxy$_$$_WeldClientProxy.java) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:383) at org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:344) at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173) at org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:341) at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:237) at org.jboss.weld.bean.proxy.ClientProxyFactory.create(ClientProxyFactory.java:105) at org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:87) at org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:43) at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:53) at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:46) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197) at com.google.common.cache.LocalCache.get(LocalCache.java:3937) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824) at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49) at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:73) at org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:102) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:621) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:653) at org.openbravo.base.weld.WeldUtils.getInstanceFromStaticBeanManager(WeldUtils.java:93) at org.openbravo.service.importprocess.ImportProcessContextListener.contextInitialized(ImportProcessContextListener.java:38) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060) at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:759) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 10475 [main] INFO org.openbravo.service.importprocess.ImportEntryManager - Calling ImportEntryManager constructor java.lang.Throwable at org.openbravo.service.importprocess.ImportEntryManager.<init>(ImportEntryManager.java:176) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.jboss.weld.introspector.jlr.WeldConstructorImpl.newInstance(WeldConstructorImpl.java:206) at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:117) at org.jboss.weld.bean.ManagedBean.createInstance(ManagedBean.java:340) at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.produce(ManagedBean.java:204) at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:296) at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103) at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) at org.openbravo.service.importprocess.ImportEntryManager$Proxy$_$$_WeldClientProxy.start(ImportEntryManager$Proxy$_$$_WeldClientProxy.java) at org.openbravo.mobile.core.process.POSTerminalContextListener.contextInitialized(POSTerminalContextListener.java:35) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060) at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:759) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) | |||||||
Steps To Reproduce | Apply simple logging diff: diff -r 65a012587054 src/org/openbravo/service/importprocess/ImportEntryManager.java --- a/src/org/openbravo/service/importprocess/ImportEntryManager.java Thu May 26 20:02:26 2016 +0200 +++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java Mon May 30 13:57:30 2016 +0200 @@ -173,6 +173,7 @@ numberOfThreads, 4); maxTaskQueueSize = ImportProcessUtils.getCheckIntProperty(log, "import.max.task.queue.size", maxTaskQueueSize, 50); + log.info("Calling ImportEntryManager constructor", new Throwable()); } public synchronized void start() { | |||||||
Tags | No tags attached. | |||||||
Attached Files | ||||||||
![]() |
|
![]() |
|
(0088511) alostale (viewer) 2016-07-15 08:46 edited on: 2016-07-15 09:04 |
See: http://stackoverflow.com/questions/18378608/why-is-constructor-of-applicationscoped-class-called-more-than-once [^] As you can see in the stack traces, 1st invocation is in a proxy and 2nd one in the actual instance. In this case the impact is reduced as the 2nd invocation is setting the correct instance and the code in the constructor itself is inexpensive. |
(0088516) hgbot (developer) 2016-07-15 10:46 |
Repository: erp/devel/pi Changeset: e05fce66f7ed8e89d6107aa70e790f973ab9d2ef Author: Asier Lostalé <asier.lostale <at> openbravo.com> Date: Fri Jul 15 09:09:26 2016 +0200 URL: http://code.openbravo.com/erp/devel/pi/rev/e05fce66f7ed8e89d6107aa70e790f973ab9d2ef [^] fixed bug 33077: ImportEntryManager constructor called twice Constructor in ImportEntryManager was invoked twice even it is a bean with application scope. The problem is CDI doesn't guarantee single constructor invocation per injection point instance as this code was asuming. The solution is to move initialization code to a method annotated with @PostConstruct. --- M src/org/openbravo/service/importprocess/ImportEntryManager.java --- |
(0088630) caristu (viewer) 2016-07-22 11:33 |
Verified in pi@ea24d6781214 |
(0089015) hudsonbot (viewer) 2016-08-11 18:40 |
A changeset related to this issue has been promoted main and to the Central Repository, after passing a series of tests. Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/edaa05b1fb18 [^] Maturity status: Test |
![]() |
|||
Date Modified | Username | Field | Change |
2016-05-30 13:58 | shuehner | New Issue | |
2016-05-30 13:58 | shuehner | Assigned To | => platform |
2016-05-30 13:58 | shuehner | OBNetwork customer | => No |
2016-05-30 13:58 | shuehner | Modules | => Core |
2016-05-30 13:58 | shuehner | Triggers an Emergency Pack | => No |
2016-07-15 08:46 | alostale | Note Added: 0088511 | |
2016-07-15 08:46 | alostale | Status | new => acknowledged |
2016-07-15 08:47 | alostale | Priority | normal => urgent |
2016-07-15 08:47 | alostale | Severity | minor => major |
2016-07-15 09:04 | alostale | Note Edited: 0088511 | View Revisions |
2016-07-15 09:04 | alostale | Severity | major => minor |
2016-07-15 09:09 | alostale | Review Assigned To | => caristu |
2016-07-15 09:13 | alostale | Status | acknowledged => scheduled |
2016-07-15 09:13 | alostale | Assigned To | platform => alostale |
2016-07-15 10:46 | hgbot | Checkin | |
2016-07-15 10:46 | hgbot | Note Added: 0088516 | |
2016-07-15 10:46 | hgbot | Status | scheduled => resolved |
2016-07-15 10:46 | hgbot | Resolution | open => fixed |
2016-07-15 10:46 | hgbot | Fixed in SCM revision | => http://code.openbravo.com/erp/devel/pi/rev/e05fce66f7ed8e89d6107aa70e790f973ab9d2ef [^] |
2016-07-22 11:33 | caristu | Note Added: 0088630 | |
2016-07-22 11:33 | caristu | Status | resolved => closed |
2016-07-22 11:33 | caristu | Fixed in Version | => 3.0PR16Q4 |
2016-08-11 18:40 | hudsonbot | Checkin | |
2016-08-11 18:40 | hudsonbot | Note Added: 0089015 |
Copyright © 2000 - 2009 MantisBT Group |