{"id":41805650,"url":"https://github.com/yskszk63/flaky-okhttp-agent","last_synced_at":"2026-01-27T13:10:50.905Z","repository":{"id":334489466,"uuid":"1141545009","full_name":"yskszk63/flaky-okhttp-agent","owner":"yskszk63","description":"A Java agent that makes OkHttp requests flaky on purpose.","archived":false,"fork":false,"pushed_at":"2026-01-25T04:21:07.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-25T18:45:47.139Z","etag":null,"topics":["429-too-many-requests","java","javaagent","okhttp3"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yskszk63.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-25T01:54:13.000Z","updated_at":"2026-01-25T04:26:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yskszk63/flaky-okhttp-agent","commit_stats":null,"previous_names":["yskszk63/flaky-okhttp-agent"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/yskszk63/flaky-okhttp-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yskszk63%2Fflaky-okhttp-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yskszk63%2Fflaky-okhttp-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yskszk63%2Fflaky-okhttp-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yskszk63%2Fflaky-okhttp-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yskszk63","download_url":"https://codeload.github.com/yskszk63/flaky-okhttp-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yskszk63%2Fflaky-okhttp-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28813296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["429-too-many-requests","java","javaagent","okhttp3"],"created_at":"2026-01-25T06:15:49.856Z","updated_at":"2026-01-27T13:10:50.890Z","avatar_url":"https://github.com/yskszk63.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flaky-okhttp-agent\n\nA Java agent that makes **OkHttp requests flaky on purpose**.\n\nThis agent intercepts OkHttp calls and intentionally returns **HTTP 429 (Too Many Requests)**,\nallowing you to test retry logic, backoff strategies, and failure handling\n*without modifying application code*.\n\n---\n\n## What this agent does\n\n- Intercepts **OkHttp** requests via Java Agent instrumentation\n- Returns **HTTP 429** for most requests\n- Allows **1 successful request every N calls**\n- Works with:\n  - HTTPS\n  - Proxy\n  - HTTP/1.1 and HTTP/2\n- Requires **no changes** to application source code\n\nThis is useful for:\n- Testing retry / backoff logic\n- Simulating rate limits\n- Chaos / fault injection in development or CI\n\n---\n\n## Usage\n\nAttach the agent using `-javaagent`:\n\n```bash\njava -javaagent:flaky-okhttp-agent.jar -jar your-app.jar\n```\n\nor\n\n```bash\nexport JAVA_TOOL_OPTIONS='-javaagent:/path/to/flaky-okhttp-agent.jar'\njava -jar your-app.jar\n```\n\nNo application code changes are required.\n\n## Download\n\n[Latest build](https://github.com/yskszk63/flaky-okhttp-agent/releases/latest/download/flaky-okhttp-agent.jar)\n\n## How it behaves\n\nBy default:\n\n- **Only 1 out of N requests succeeds**\n- The remaining requests return **429 Too Many Requests**\n\nExample with `FOA_SUCCESS_EVERY_NTH_REQUEST=5`:\n\n| Request # | Result        |\n|----------:|---------------|\n| 1         | 429           |\n| 2         | 429           |\n| 3         | 429           |\n| 4         | 429           |\n| 5         | ✅ success    |\n| 6         | 429           |\n| ...       | ...           |\n\n---\n\n## Configuration\n\nConfiguration is done via **environment variables**.\n\n### `FOA_SUCCESS_EVERY_NTH_REQUEST`\n\nControls how often a request is allowed to succeed.\n\n- Type: integer\n- Meaning: **1 successful request every N requests**\n- Default: `2`\n\n### `FOA_TARGET_HOST`\n\nLimits the agent behavior to a specific host.\n\n- Type: string\n- Matching: **exact match**\n- Default: *(not set)* — applies to **all hosts**\n\nWhen this variable is set, the agent logic is applied **only if the request host exactly matches**\nthe specified value.\n\n### `FOA_FAILURE_STATUS`\n\nSpecifies the HTTP status code returned for injected failures.\n\n- Type: integer (HTTP status code)\n- Default: `429`\n\nWhen this variable is set, the agent returns the specified status code\ninstead of `429 Too Many Requests` for failure responses.\n\n---\n\n## Scope and limitations\n\n- This agent only targets OkHttp\n- Other HTTP clients (HttpURLConnection, Apache HttpClient, etc.) are not affected\n- Designed for testing and development\n- Not recommended for production environments\n\n### Limitations: Multiple ClassLoaders\n\nThis agent is designed to work with applications that use a **single application classloader**\nor a relatively simple classloader hierarchy.\n\nIt may **not work correctly** in environments that heavily rely on\n**multiple or isolated classloaders**, such as:\n\n- Servlet containers (e.g. Tomcat, Jetty)\n- Application servers\n- OSGi-based runtimes\n- Other plugin-based architectures\n\nIn such environments, OkHttp may be loaded by a different classloader than the one\ninstrumented by the agent, causing the interception logic to be skipped or applied inconsistently.\n\n#### Notes\n\n- This agent targets OkHttp clients created in the main application classloader\n- Behavior in multi-classloader environments is **undefined**\n- This is a known limitation of the current implementation. Improved support for multi-classloader environments may be explored in the future.\n\nFor these reasons, this agent is intended for:\n- Standalone applications\n- CLI tools\n- Test environments\n- CI pipelines\n\nand is **not recommended** for servlet-based or application-server deployments.\n\n---\n\n## Implementation notes\n\n- Uses OkHttp's internal interceptor chain\n- Does not modify sockets, TLS, or proxy settings\n- Safe to use with shaded or relocated OkHttp dependencies\n\n---\n\n## Why not randomness?\n\nThis agent uses deterministic failure (N requests → 1 success)\ninstead of probability-based failure.\n\nReasons:\n\n- Reproducible behavior\n- Easier debugging\n- More predictable tests\n\n---\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyskszk63%2Fflaky-okhttp-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyskszk63%2Fflaky-okhttp-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyskszk63%2Fflaky-okhttp-agent/lists"}