{
  "id": "java/assertion-error-expected-not-null",
  "signature": "java.lang.AssertionError: expected null, but was: <some value>",
  "signature_zh": "java.lang.AssertionError: 期望为 null，但实际为：<某个值>",
  "regex": "java\\.lang\\.AssertionError: expected null, but was: <.*>",
  "domain": "java",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "An assertion in the code (typically from a test framework like JUnit or an explicit assert statement) failed because a value that was expected to be null was not null, indicating a logic error in null handling.",
  "root_cause_type": "generic",
  "root_cause_zh": "代码中的断言（通常来自 JUnit 等测试框架或显式的 assert 语句）失败，因为期望为 null 的值实际不为 null，表明空值处理存在逻辑错误。",
  "versions": [
    {
      "version": "JUnit 4.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "JUnit 5.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Java 8+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Remove the assertion entirely from the code",
      "why_fails": "This suppresses the symptom but does not fix the underlying null-handling bug; the logic may still produce incorrect results.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Change the expected value in the assertion to match the actual value",
      "why_fails": "This bypasses the validation and may hide a real bug where null was expected but a non-null value indicates an error in the system.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a try-catch block to swallow the AssertionError",
      "why_fails": "AssertionErrors are not meant to be caught; swallowing them violates the intent of the assertion and can lead to silent failures.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Trace back to the source of the non-null value. For example, if a method is expected to return null but returns a value, add debug logging: System.out.println(\"Value: \" + value); and check the method's logic.",
      "success_rate": 0.8,
      "how": "Trace back to the source of the non-null value. For example, if a method is expected to return null but returns a value, add debug logging: System.out.println(\"Value: \" + value); and check the method's logic.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a conditional breakpoint in the IDE (e.g., IntelliJ IDEA) set on the assertion line to inspect variables when the assertion fails.",
      "success_rate": 0.85,
      "how": "Use a conditional breakpoint in the IDE (e.g., IntelliJ IDEA) set on the assertion line to inspect variables when the assertion fails.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using JUnit, replace assertNull with assertNotNull if the expectation is incorrect, or use assertNull(obj, \"message\") to add a descriptive message for debugging.",
      "success_rate": 0.75,
      "how": "If using JUnit, replace assertNull with assertNotNull if the expectation is incorrect, or use assertNull(obj, \"message\") to add a descriptive message for debugging.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Trace back to the source of the non-null value. For example, if a method is expected to return null but returns a value, add debug logging: System.out.println(\"Value: \" + value); and check the method's logic.",
    "Use a conditional breakpoint in the IDE (e.g., IntelliJ IDEA) set on the assertion line to inspect variables when the assertion fails.",
    "If using JUnit, replace assertNull with assertNotNull if the expectation is incorrect, or use assertNull(obj, \"message\") to add a descriptive message for debugging."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/AssertionError.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}