Skip to content

Conversation

@Jonas-Isr
Copy link
Member

@Jonas-Isr Jonas-Isr commented Nov 27, 2025

Context

SAP/cloud-sdk-java-backlog#495

This PR improves the circuit breaker logic by prepending an additional check to tryGetDestination. When a single destination is called, it is first checked whether this destination appears in the result of a get all destination call. If the destination is not present, no call to the destination is made. Thus the circuit breaker does not open when non-existing destination(s) are called multiple times.

This new behaviour is implemented as opt-in to not introduce breaking changes.

Feature scope:

  • Add additional check
  • add feature switch to turn on new additional check

Definition of Done

@Jonas-Isr Jonas-Isr self-assigned this Nov 28, 2025
@Jonas-Isr Jonas-Isr added do not merge Pull request must not be merged please review Request to review a pull request labels Nov 28, 2025
.when(destinationServiceAdapter)
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());

DestinationService.Cache.setGetAllDocumentsPrepended(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Major)

Please consider different API options, to reflect on existing available methods.

- DestinationService.Cache.setGetAllDocumentsPrepended(true);

+ DestinationService.Cache.enableGetAllDocumentsPrepended();
+ DestinationService.Cache.enableGetAllDestinationsPrepended();
+ DestinationService.Cache.enablePreLookupCheck();
+ DestinationService.Cache.enableExistenceCheck();

Also your feature would be enabled by default - right?

Copy link
Member Author

@Jonas-Isr Jonas-Isr Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it to DestinationService.Cache.enablePreLookupCheck().

Right now I have so that the behaviour is disabled by default. I did that to not introduce breaking changes (and also we talked about that this might increase response times for the first call). Do you think it should be enabled by default?

Comment on lines 157 to 160
if( prependGetAllDestinationCall && !destinationExists() ) {
final String msg = "Destination %s was not found among the destinations of the current tenant.";
return Try.failure(new DestinationAccessException(String.format(msg, destinationName)));
}
Copy link
Contributor

@newtork newtork Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Question/Minor)

Not a huge fan of Boolean (sic) prependGetAllDestinationCall additional 7th argument.
Have you considered wrapping this check into destinationRetriever argument before calling the method? If it's not too complex/too much additional code (likely).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean was a typo, should of course have been boolean 😬

I struggled a bit with placing this into destinationRetriever but found another solution by putting it directly into DestinationService.tryGetDestination. Is there anything that speaks against this?

Copy link
Member

@rpanackal rpanackal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Question)

So the idea was instead of directly augmenting resilience config cache key, we introduce a (opt-in) check for the existence of a destination, essentially avoid tripping the circuit breaker in the first place.

But, I wonder what if a destination call fails for a different reason than DestinationAccessException? Is that possible? If so, I don't see how the current approach would resolve the issue?

@Jonas-Isr
Copy link
Member Author

But, I wonder what if a destination call fails for a different reason than DestinationAccessException? Is that possible? If so, I don't see how the current approach would resolve the issue?

Yes, this is indeed possible and this approach does not solve the issue. We discussed this and came to the conclusion that the problem we solve with the current approach is the main problem we want to solve. Solving the issue you describe here might lead to unexpected behaviour of the SDK so we decided against trying to solve that. Our hope was that by adding this additional check we solve the main amount of problems.

newtork
newtork previously approved these changes Dec 8, 2025
@newtork newtork dismissed their stale review December 8, 2025 10:23

I was made aware we want this to be "opt-out" instead of "opt-in" (?)

@Jonas-Isr Jonas-Isr removed the do not merge Pull request must not be merged label Dec 8, 2025
@Jonas-Isr
Copy link
Member Author

Jonas-Isr commented Dec 8, 2025

I was made aware we want this to be "opt-out" instead of "opt-in" (?)

I adapted the code accordingly.

Also, I would say it is not necessary to write specific docs for this (besides the release notes). Do you agree?

I wrote some docs now.

newtork
newtork previously approved these changes Dec 9, 2025
Copy link
Member

@rpanackal rpanackal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jonas-Isr Jonas-Isr merged commit 6190334 into main Dec 16, 2025
14 checks passed
@Jonas-Isr Jonas-Isr deleted the circuit-breaker branch December 16, 2025 10:24
newtork added a commit that referenced this pull request Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

please review Request to review a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants