CPS-738 - Getting issue details... STATUS


Issue Reported:

Application start up failing due to cyclic dependency :

┌─────┐
|  notificationService defined in URL
[jar:file:/app/libs/cps-service-2.0.1-SNAPSHOT.jar!/org/onap/cps/notification/NotificationService.class]
↑     ↓
|  cpsDataUpdatedEventFactory defined in URL
[jar:file:/app/libs/cps-service-2.0.1-SNAPSHOT.jar!/org/onap/cps/notification/CpsDataUpdatedEventFactory.class]
↑     ↓
|  cpsDataServiceImpl (field private
org.onap.cps.notification.NotificationService
org.onap.cps.api.impl.CpsDataServiceImpl.notificationService)
└─────┘

What caused the cyclic dependency :

Spring by default performs the bean initialization at the startup of the application. Hence cyclic dependencies lead to issues because each components keep waiting for its dependencies to be initialized first.



Proposal 1: To remove the cyclic dependency



Pros:

  • Removes Cyclic Dependency
  • Makes getDataNode and getAnchor method calls synchronous, thus addressing the issue related to data corruption in case of concurrent update.

Cons:

  • Making getDataNode and getAnchor method calls synchronous could lead to increased latency of the APIs

Proposal 2 : Fixing the issue by Lazy Initialization

The lazy initialization concept simply means initialize something when needed. So lazy initialization of bean means bean will be initialized at the time of its demand instead of start up.

Lazy Intitialization of cpsDataServiceImpl in cpsDataUpdatedEventFactory component.  This will ensure that CpsDataUpdatedEventFactory will not keep waiting for CpsDataServiceImpl to be initialized first thus resolving the cyclic dependency error at start up.



  • No labels