{
  "id": "java/mockito-answer-throws-exception",
  "signature": "org.mockito.exceptions.stubbing.AnswerException: Exception thrown by answer: java.lang.RuntimeException: test exception",
  "signature_zh": "回答异常：回答抛出异常：java.lang.RuntimeException: test exception",
  "regex": "org\\.mockito\\.exceptions\\.stubbing\\.AnswerException:\\ Exception\\ thrown\\ by\\ answer:\\ java\\.lang\\.RuntimeException:\\ test\\ exception",
  "domain": "java",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Custom Answer implementation throws an exception when invoked during test.",
  "root_cause_type": "generic",
  "root_cause_zh": "自定义 Answer 实现 在测试调用期间抛出异常。",
  "versions": [
    {
      "version": "8+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Catching exception in test and ignoring",
      "why_fails": "Hides the real issue; test may pass incorrectly.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using thenThrow instead of custom Answer",
      "why_fails": "May not match the intended behavior if Answer has complex logic.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fix Answer implementation to handle edge cases",
      "success_rate": 0.9,
      "how": "Answer<String> answer = invocation -> {\n    if (invocation.getArgument(0) == null) {\n        return \"default\";\n    }\n    return invocation.getArgument(0).toString();\n};",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use thenAnswer with lambda",
      "success_rate": 0.85,
      "how": "when(mock.method(any())).thenAnswer(invocation -> {\n    // safe logic\n    return \"result\";\n});",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}