Fix JsonSchema null collection fields causing serialization failures by rameshreddy-adutla · Pull Request #853 · modelcontextprotocol/java-sdk
When an MCP server (e.g. Python/fastmcp) omits optional schema fields like required, $defs, and definitions, Jackson deserializes them as null. This causes failures when callers re-serialize the JsonSchema with a standard ObjectMapper or iterate over these collections. Add a compact constructor that defaults null collection fields to empty immutable collections (List.of(), Map.of()). Also add @JsonInclude(NON_EMPTY) on collection fields so that empty defaults are omitted during serialization, preserving wire format compatibility. Fixes modelcontextprotocol#664 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>