Skip to content

Commit

Permalink
Fix the max. # of lens context reload attempts
Browse files Browse the repository at this point in the history
We don't want to leave the context rotten after too many attempts.

Related to MID-7725.

(cherry picked from commit 080c22c)
  • Loading branch information
mederly committed Mar 23, 2022
1 parent f4a0fde commit ca4caf4
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <F extends ObjectType> void load(@NotNull LensContext<F> context, @NotNull Strin
throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException,
SecurityViolationException, PolicyViolationException, ExpressionEvaluationException {

for (int attempt = 1; attempt <= MAX_LOAD_ATTEMPTS; attempt++) {
for (int loadAttempt = 1; ; loadAttempt++) {
Set<String> modifiedOids = new HashSet<>();
FocusChangeExecution.ChangeExecutionListener listener = modifiedOids::add;
FocusChangeExecution.registerChangeExecutionListener(listener);
Expand All @@ -97,15 +97,20 @@ <F extends ObjectType> void load(@NotNull LensContext<F> context, @NotNull Strin
LOGGER.trace("Focus OID/OIDs modified during load operation in this thread: {}", modifiedOids);
LensFocusContext<F> focusContext = context.getFocusContext();
if (focusContext != null && focusContext.getOid() != null && modifiedOids.contains(focusContext.getOid())) {
LOGGER.debug("Detected modification of the focus during 'load' operation, retrying the loading (#{})", attempt);
context.rot("focus modification during loading");
if (loadAttempt == MAX_LOAD_ATTEMPTS) {
LOGGER.warn("Focus was repeatedly modified during loading too many times ({}) - continuing,"
+ " but it's suspicious", MAX_LOAD_ATTEMPTS);
return;
} else {
LOGGER.debug("Detected modification of the focus during 'load' operation, retrying the loading (#{})",
loadAttempt);
context.rot("focus modification during loading");
}
} else {
LOGGER.trace("No modification of the focus during 'load' operation, continuing");
return;
}
}
LOGGER.warn("Focus was repeatedly modified during loading ({} times) - continuing, but it's suspicious",
MAX_LOAD_ATTEMPTS);
}

public <O extends ObjectType> void loadFocusContext(LensContext<O> context, Task task, OperationResult parentResult)
Expand Down

0 comments on commit ca4caf4

Please sign in to comment.