question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TimeLimiter for methods returning void

See original GitHub issue

I am having to implement TimeLimiter for a method which has void return type, but I noticed that TimeLimiter only has decorateFutureSupplier which cannot take a method which returns void. Can you please let me know how this can be implemented?

My situation is that the method I am using from an external library and I cannot change its signature. So I will really appreciate any help on this topic.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Romehcommented, Jun 20, 2019

for point 1: this was typo , it was meant to be waitDurationInOpenState , it is updated now on the docs for point 2 : after u add the r4j spring boot starter and the config in ur yaml file , you just inject CircuitBreakerRegistry bean in your spring managed service/component then get the target circuit breaker by its instance name : io.github.resilience4j.circuitbreaker.CircuitBreaker circuitBreaker = circuitBreakerRegistry.circuitBreaker(instanceName);

1reaction
RobWincommented, Jun 19, 2019

Depends on the decoration order and your CircuitBreakerConfig. In @hexmind example, yes. But you could also ignore TimeoutExceptions

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resilience4j with spring boot - java - Stack Overflow
Earlier, i used CircuitBreaker and Retry annotations with void method. It worked. But Timelimiter was not working.
Read more >
Timeouts with Spring Boot and Resilience4j - Reflectoring
Continuing the Resilience4j journey, this article on Spring Boot TimeLimiter shows when and how to use it to build resilient applications.
Read more >
TimeLimiter (Guava: Google Core Libraries for Java 22.0 API)
Returns an instance of interfaceType that delegates all method calls to the target object, enforcing the specified time limit on each call. void...
Read more >
Mocking Void Methods with Mockito - Baeldung
See how to mock methods that return void using Mockito.
Read more >
OperationalConfig (Oracle Fusion Middleware Java API Reference ...
Sets default sizelimit, maximum number of entities to be returned in search methods. void, setTimeLimit(int timeLimit). Sets default timelimit, maximum time ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found