Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public interface CancellationToken {
* Will be called if one step during the whole polling mechanism is done and the next iteration
* will start afterwards.
*/
void step();
void nextStep();

/** Will wait a dedicated amount of time before starting the next step. */
void waitBeforeStartingNextStep();
void waitIfNotCancelled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ public boolean isNotCancelled() {
}

@Override
public void step() {
public void nextStep() {
nrOfTries++;
}

@Override
public void waitBeforeStartingNextStep() {
try {
Thread.sleep(timeToWait);
} catch (InterruptedException nop) {
wasInterrupted = true;
public void waitIfNotCancelled() {
if (isNotCancelled()) {
try {
Thread.sleep(timeToWait);
} catch (InterruptedException nop) {
wasInterrupted = true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ default Optional<String> poll(
if (!StringUtils.equalsIgnoreCase(entityContent, EMPTY_CONTENT)) {
return Optional.of(entityContent);
}
cancellationToken.step();
cancellationToken.waitBeforeStartingNextStep();
cancellationToken.nextStep();
cancellationToken.waitIfNotCancelled();
}
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public boolean isNotCancelled() {
}

@Override
public void step() {
public void nextStep() {
// NOP
}

@Override
public void waitBeforeStartingNextStep() {
public void waitIfNotCancelled() {
// NOP
}
});
Expand Down