{"record":{"id":"07b85952b02c0a8c","repo":"stanfordnlp/CoreNLP","slug":"should-not-reach-this-switch-case","errorCode":null,"errorMessage":"Should not reach this switch case","messagePattern":"Should not reach this switch case","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/logging/SLF4JHandler.java","lineNumber":91,"sourceCode":"    }\n\n    // Route the signal\n    switch (loggerAndLevel.second) {\n      case ERROR:\n        loggerAndLevel.first.error(line);\n        break;\n      case WARN:\n        loggerAndLevel.first.warn(line);\n        break;\n      case DEBUG:\n        loggerAndLevel.first.debug(line);\n        break;\n      case STDOUT:\n      case STDERR:\n        loggerAndLevel.first.info(line);\n        break;\n      case FORCE:\n        throw new IllegalStateException(\"Should not reach this switch case\");\n      default:\n        throw new IllegalStateException(\"Unknown Redwood flag for slf4j integration: \" + loggerAndLevel.second);\n    }\n  }\n\n}\n","sourceCodeStart":73,"sourceCodeEnd":98,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/logging/SLF4JHandler.java#L73-L98","documentation":"SLF4JHandler.print() switches over a per-target Redwood flag (FORCE/STDOUT/STDERR/etc.) paired with an SLF4J logger. FORCE is an internal marker that should never reach this switch; hitting it means the handler's internal state is corrupted or was constructed inconsistently.","triggerScenarios":"Internal: a record routed to an SLF4JHandler whose loggerAndLevel.second is the FORCE flag — only possible if handler construction/pairing logic changed or a custom subclass injected bad state.","commonSituations":"Practically never seen by library users; appears if SLF4JHandler internals are patched, deserialized incorrectly, or a custom LogRecordHandler feeds targets into it incorrectly.","solutions":["Report/inspect how SLF4JHandler's loggerAndLevel pairs were constructed; ensure no custom code sets the FORCE flag as a target level.","Use an unmodified SLF4JHandler from a matching library version (stale patched jar is a common cause).","Work around by using Handlers.output or stderr instead of SLF4JHandler while investigating."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  config.handlers(Handlers.slf4j).apply();\n} catch (IllegalStateException e) {\n  if (e.getMessage().contains(\"Should not reach this switch case\")) {\n    log.error(\"SLF4JHandler internal invariant broken; cause:\", e);\n    RedwoodConfiguration.empty().handlers(Handlers.stderr).apply();\n  } else throw e;\n}","preventionTips":["Do not patch or subclass SLF4JHandler to inject custom target flags.","Use only factory paths (Handlers.slf4j) to construct the handler.","Keep all Redwood/CoreNLP jars at one version."],"tags":["logging","slf4j","internal-state","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}