resilience4cata 1.1.1 is on Maven Central. Together with 1.1.0, it brings nine fixes since 1.0.0. All of them are compatible: the API, the generated code and the configuration keys are unchanged, so upgrading is a version bump.

If you haven't seen it before: resilience4cata gives you retry, circuit breaker, rate limiter, timeout, bulkhead, fallback, hedging and an adaptive concurrency limit for Java 21+. You write them as annotations, and an annotation processor turns them into plain Java at compile time, with no proxies, aspects or agents.

Some of these bugs were found by going through Resilience4j's test suite and checking the same cases here. Here is what changed, grouped by where you would have noticed it.

Reactor: cancelling a Flux (1.1.0)

Two bugs had the same cause: what happens when a subscriber cancels a Flux.

  • next() and take(1) left no success in the circuit breaker. Those operators cancel the stream after its first element, and a cancelled call was not recorded at all. A few failures among many healthy streams could open the breaker, and a half-open probe read this way never closed it. Now a cancel after the first element counts as a success (or as a slow call, if that element was slow). A cancel before the first element is still not recorded.
  • A Pipeline on a Flux lost the cancel. With FluxPipelineOperator and neither a retry nor a fallback, cancelling the subscription never reached the policies. The bulkhead kept its slot for good, so later calls were rejected, and the source stayed subscribed. Code generated from annotations was not affected, only the programmatic Pipeline.

The first one is the only change of behaviour in these releases. If your breaker thresholds were tuned around streams that were never recorded, it may now see more successes than before. The Flux section of the Reactor guide describes the rule.

Timeouts on machines that oversleep (1.1.0)

Synchronous timeouts are driven by a watchdog thread that sleeps in short steps and keeps a coarse clock. That clock moved forward by at most one tick per wake-up. On machines where a short sleep always lasts longer than asked, it fell behind real time, and every sync timeout with it. On GitHub's macOS VMs, a sleep of 0.75 ms took about 4 ms, and a 200 ms timeout fired after 760 ms. The weekly build on Windows and macOS caught it.

Now the clock's step follows how long the watchdog actually slept, so it keeps up with real time, and a timeout still never fires early. On a machine that wakes up on time, nothing changes. See the Timeout policy.

Edge cases of time arithmetic (1.1.0 and 1.1.1)

  • The rate limiter could judge a call with a clock reading older than another thread's permit. Its wait came out too long by the time between the two reads, and with maxWait = 0 it could reject the call for no reason.
  • Retry delays close to Long.MAX_VALUE nanoseconds overflowed: full jitter threw IllegalArgumentException, and maxDuration could let a retry through past its limit.
  • Durations longer than about 292 years in a *Config builder, a Pipeline step or ResilienceRegistry.Builder are now rejected at once with R4C-REG-001, naming the attribute. Before, they failed later, when the policy was created, with a bare ArithmeticException. Annotations and configuration files already rejected them.

Nobody configures a 292-year timeout on purpose. But a value like that can come from a computation or a misread property, and the error should say which attribute is wrong.

Micronaut: verify-instances: off in YAML (1.1.1)

This one stopped applications from starting. The Micronaut guide showed:

resilience4cata: micronaut: verify-instances: off 

YAML reads an unquoted off as the boolean false, so the integration received "false" and rejected it with R4C-MN-006. Now false means off. The valid values are fail, warn and off, so an unquoted on (read as true) is still rejected, now with a hint to quote the value.

Metrics after a registry is gone (1.1.1)

  • OpenTelemetry: binding a ResilienceRegistry kept it alive until close(). A registry the application dropped was never collected, and its gauges kept reporting. Now they stop when the registry is collected.
  • Micrometer: when a bound registry was collected, a registry bound later with an instance of the same id never got gauges, and its state stayed NaN. It now takes over the stale gauges.

How compatibility was checked

Every 1.x release has to keep the compatibility promise, and CI checks it on every change:

  • API: japicmp compares every published module with the last release. It found no incompatible change against 1.1.0.
  • Generated code: the example tests are compiled with the last release's annotation processor and run on the new runtime.
  • Configuration: a file that uses every configuration key of each release must be read the same way by every later version.
  • Contracts: the metric names, error codes and snapshot paths are checked against files kept in the repository.

Upgrade

dependencies { implementation 'dev.resilience4cata:resilience4cata-all:1.1.1' annotationProcessor 'dev.resilience4cata:resilience4cata-processor:1.1.1' } 

With the BOM, change its version to 1.1.1. For Maven, see the installation page. The full list is in the changelog.

If you are new to the library, the quickstart takes about five minutes. If you use Resilience4j today, start with the migration guide.

Feedback

If something surprised you, or an error message didn't tell you what to do, please open an issue.

The code is Apache-2.0 on GitHub.