CtrlK
BlogDocsLog inGet started
Tessl Logo

martinfrancois/java-optionals

Help AI coding agents use Java Optional well in new code and cleanups, without replacing one antipattern with another.

100

2.08x
Quality

100%

Does it follow best practices?

Impact

100%

2.08x

Average score across 4 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-2/

Write retry backoff code

Create RetryBackoff.java. Assume Java 17.

Implement:

Duration backoff(Config config, int attempt, HttpResponse<?> response)

Rules:

  • If response is not null and has a valid Retry-After header, return that duration.
  • A valid Retry-After value is a positive whole number of seconds.
  • If the header is missing, blank, zero, negative, or not a number, return the exponential backoff.
  • The exponential backoff is config.baseDelay().multipliedBy(1L << Math.min(attempt - 1, 8)).
  • Include Optional<Duration> parseRetryAfter(String value).
  • Include this nested record:
record Config(Duration baseDelay) {}

README.md

tile.json