{"id":15329435,"url":"https://github.com/tisonkun/failpoints","last_synced_at":"2025-04-15T02:53:52.531Z","repository":{"id":103983477,"uuid":"523373650","full_name":"tisonkun/failpoints","owner":"tisonkun","description":"An implementation of failpoints for Java.","archived":false,"fork":false,"pushed_at":"2024-03-23T02:53:19.000Z","size":104,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T02:53:46.309Z","etag":null,"topics":["failpoint","failure-injection","fault-injection","java","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tisonkun.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}},"created_at":"2022-08-10T14:21:50.000Z","updated_at":"2024-06-27T09:34:20.000Z","dependencies_parsed_at":"2024-03-23T01:27:18.793Z","dependency_job_id":"f9ea0849-9e5c-4d66-8b22-8779a6e4b428","html_url":"https://github.com/tisonkun/failpoints","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tisonkun%2Ffailpoints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tisonkun%2Ffailpoints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tisonkun%2Ffailpoints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tisonkun%2Ffailpoints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tisonkun","download_url":"https://codeload.github.com/tisonkun/failpoints/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997089,"owners_count":21195797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["failpoint","failure-injection","fault-injection","java","testing"],"created_at":"2024-10-01T09:47:50.984Z","updated_at":"2025-04-15T02:53:52.516Z","avatar_url":"https://github.com/tisonkun.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Failpoints\n\n![Maven Central Version](https://img.shields.io/maven-central/v/org.tisonkun.failpoints/failpoints-api)\n\nAn implementation of [failpoints](http://www.freebsd.org/cgi/man.cgi?query=fail) for Java. Fail points are used to add code points where errors may be injected in a user controlled fashion. Fail point is a code snippet that is only executed when the corresponding failpoint is active.\n\n## Quick Start\n\n1. Add failpoints library in dependencies.\n\n```xml\n\u003cdependencies\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.tisonkun.failpoints\u003c/groupId\u003e\n  \u003cartifactId\u003efailpoints-api\u003c/artifactId\u003e\n  \u003cversion\u003e2.1.1\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.tisonkun.failpoints\u003c/groupId\u003e\n    \u003cartifactId\u003efailpoints-simple\u003c/artifactId\u003e\n    \u003cversion\u003e2.1.1\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n2. Inject failpoints to your program, eg:\n\n```java\nimport org.tisonkun.failpoints.Failpoints;\n\npublic class TestingObject {\n    public void testInject(Runnable r) {\n        Failpoints.inject(getClass(), \"testing-object\", v -\u003e {\n            if (v != null \u0026\u0026 (boolean) v) {\n                r.run();\n            }\n        });\n    }\n}\n```\n\n3. In testing code, enable the failpoint:\n\n```java\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.TimeUnit;\nimport org.junit.jupiter.api.Assertions;\nimport org.junit.jupiter.api.Test;\nimport org.tisonkun.failpoints.FailpointGuard;\nimport org.tisonkun.failpoints.Failpoints;\n\npublic class SimpleFailpointDriverTest {\n    public void testInjectFailpoint() throws Exception {\n        try (final FailpointGuard ignored = Failpoints.enable(TestingObject, \"testing-object\", true)) {\n            final CountDownLatch latch = new CountDownLatch(1);\n            new TestingObject().testInject(latch::countDown);\n            Assertions.assertTrue(latch.await(1000, TimeUnit.MILLISECONDS));\n        }\n        final CountDownLatch latch = new CountDownLatch(1);\n        new TestingObject().testInject(latch::countDown);\n        Assertions.assertFalse(latch.await(1000, TimeUnit.MILLISECONDS));\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftisonkun%2Ffailpoints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftisonkun%2Ffailpoints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftisonkun%2Ffailpoints/lists"}