stanfordnlp/CoreNLP · error · IllegalStateException
Should not reach this switch case
Error message
Should not reach this switch case
What it means
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.
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
config.handlers(Handlers.slf4j).apply();
} catch (IllegalStateException e) {
if (e.getMessage().contains("Should not reach this switch case")) {
log.error("SLF4JHandler internal invariant broken; cause:", e);
RedwoodConfiguration.empty().handlers(Handlers.stderr).apply();
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Practically never seen by library users; appears if SLF4JHandler internals are patched, deserialized incorrectly, or a custom LogRecordHandler feeds targets into it incorrectly.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Could not find SLF4J in your classpath
- Unknown default state setting:
- Unknown Redwood flag for slf4j integration:
- adjustFinalToken: Unexpected final char: |
- after blockInitialize, param Index ( ) not equal to…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/07b85952b02c0a8c.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/logging/SLF4JHandler.java:91
}
// Route the signal
switch (loggerAndLevel.second) {
case ERROR:
loggerAndLevel.first.error(line);
break;
case WARN:
loggerAndLevel.first.warn(line);
break;
case DEBUG:
loggerAndLevel.first.debug(line);
break;
case STDOUT:
case STDERR:
loggerAndLevel.first.info(line);
break;
case FORCE:
throw new IllegalStateException("Should not reach this switch case");
default:
throw new IllegalStateException("Unknown Redwood flag for slf4j integration: " + loggerAndLevel.second);
}
}
}
View on GitHub (pinned to 1b7edd19c4)