Fix for endless loop when an exception of type EntityAlreadyExistsException is thrown in the context of the retryable findOrRegisterTargetIfItDoesNotExist method (#828)

* fixed typo in method name

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* Added recover method to handle EntityAlreadyExistsException

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* Added tests

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* Apply suggestions from code review

Use thenThrow(Exception.class) instead of (new Exception())

Co-Authored-By: a-sayyed <ahmed.sayed@bosch-si.com>

* Apply suggestions from code review

use final modifier

Co-Authored-By: a-sayyed <ahmed.sayed@bosch-si.com>

* Adapted review findings

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* Adapted review findings

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>

* added logs for EntityAlreadyExistsException case

Signed-off-by: Ahmed Sayed <ahmed.sayed@bosch-si.com>
This commit is contained in:
Ahmed Sayed
2019-04-30 12:47:06 +02:00
committed by Dominic Schabel
parent ed95ae6398
commit 9884452ad4
10 changed files with 137 additions and 26 deletions

View File

@@ -143,7 +143,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
@PathVariable("controllerId") final String controllerId) {
LOG.debug("getControllerBase({})", controllerId);
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, IpUtil
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist(controllerId, IpUtil
.getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties));
final Action action = controllerManagement.findOldestActiveActionByTarget(controllerId).orElse(null);