{
  "id": 3882287,
  "title": "Making HTTP Fail on Purpose: Building a Small Chaos Library for Java - Flaky HTTP",
  "url": "https://urgent.news/2026/08/28/making-http-fail-on-purpose-building-a-small-chaos-library-for-java",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-28T03:46:54.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/tapadyutichatterjee/making-http-fail-on-purpose-building-a-small-chaos-library-for-java-flaky-http-18ia"
  },
  "original_language": "en",
  "account": "Flaky HTTP is a lightweight Java 11 library designed to intentionally make HTTP calls less reliable. It may seem counterintuitive, but ensuring HTTP reliability is crucial. Developers often incorporate retries, timeouts, circuit breakers, fallbacks, caches, and monitoring to achieve this. However, validating the effectiveness of these reliability mechanisms can be challenging.\n\nThe initial concept was straightforward: wrap Java's standard HttpClient, introduce controlled latency or synthetic HTTP errors to specific requests, and maintain the rest of the application unaltered. This led to several noteworthy design choices regarding API design, asynchronous cancellation, response body handling, deterministic testing, and the distinction between application-level failure injection and genuine network chaos.\n\nThis article extends beyond a mere release announcement, aiming to elucidate the library's purpose, internal workings, utility, and limitations. TL;DR Flaky HTTP is a lightweight wrapper around Java 11's java.net.http.HttpClient, offering the following capabilities:\n\n1. Introducing fixed or random latency\n2. Delivering synthetic HTTP errors with configurable probability\n3. Targeting requests using full-URI regular expressions\n4. Managing synchronous and asynchronous calls\n5. Propagating cancellation for delayed asynchronous operations\n6. Functioning without additional runtime dependencies beyond Java 11\n\nThe Maven coordinate for the library is com.tapadyuti:flaky-http:1.0.0. The simplest way to set up a test with deterministic failure is by creating a FlakyConfig object with a failure rate of 1.0 and an error status of 503. Subsequently, every targeted call returns an empty synthetic 503 response, bypassing the network. To adjust the test for slowness without an HTTP error, replace 1.0 with 0.0 and apply a LatencyStrategy.fixed(500) strategy.\n\nFlaky HTTP is intended for integration tests, resilience tests, local development, and controlled demonstrations. It should not replace a network proxy or a full chaos-engineering platform.\n\nThe underlying architecture, codebase, and implementation decisions are entirely my own creation. The inspiration stemmed from the desire to simplify the testing of HTTP integrations, where failure setups often become more intricate than the behavior being tested. Developers may need to modify mock servers, add proxy rules, adjust container networking, or create unique test doubles for every client abstraction. Flaky HTTP provides a more streamlined solution for a common case scenario.",
  "summary": "I recently built and open-sourced Flaky HTTP , a small Java 11 library for deliberately making HTTP calls less reliable. That may sound like an unusual goal. Most of the time, we work hard to make HTTP calls reliable. We add retries, timeouts, circuit breakers, fallbacks, caches, and monitoring. But eventually we need to answer a more difficult question: How do we know any of that behavior…",
  "key_points": [
    "Flaky HTTP is a lightweight Java 11 library",
    "Introduces controlled latency and synthetic HTTP errors",
    "Targets requests using full-URI regular expressions"
  ],
  "editors_take": "This library fills a gap in testing tools by allowing developers to easily simulate unreliable HTTP connections, making it simpler to validate the effectiveness of their reliability mechanisms.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}