Skip to content

Commit

Permalink
Avoid circular reference problem on container start, fixes #944
Browse files Browse the repository at this point in the history
- some assert services where used by caller side but reuse them as well
- so it was not clear for the framework which one would be
  initialized first.
- To avoid this, the assert services get the callers injected lazy, so
  only necessary at runtime when instances are already created
  • Loading branch information
de-jcup committed Feb 9, 2022
1 parent 80e6023 commit 11ae381
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package com.daimler.sechub.domain.scan;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import com.daimler.sechub.domain.scan.access.ScanUserAccessToProjectValidationService;
Expand All @@ -21,6 +22,7 @@ public class ScanAssertService {
@Autowired
ScanUserAccessToProjectValidationService userAccessValidation;

@Lazy
@Autowired
ScanProjectConfigAccessLevelService accessLevelService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import com.daimler.sechub.domain.schedule.access.ScheduleUserAccessToProjectValidationService;
Expand All @@ -32,6 +33,7 @@ public class ScheduleAssertService {
@Autowired
ProjectWhiteListSecHubConfigurationValidationService executionIsInWhiteListValidation;

@Lazy
@Autowired
SchedulerProjectConfigService projectConfigService;

Expand Down
2 changes: 0 additions & 2 deletions sechub-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ spring:
main:
# see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#bean-overriding
allow-bean-definition-overriding: true
# see https://stackoverflow.com/questions/70036903/spring-boot-application-fails-to-start-after-upgrading-to-2-6-0-due-to-circular
allow-circular-references: true
servlet:
# MultiPart file-size limits,
# https://spring.io/guides/gs/uploading-files/
Expand Down

0 comments on commit 11ae381

Please sign in to comment.