Skip to content

2.6.0

Choose a tag to compare

@jwcarman jwcarman released this 18 Apr 18:27
· 24 commits to main since this release

New Features

  • Exception-to-JSON-RPC-error translator SPI — new JsonRpcExceptionTranslator<E extends Exception> and JsonRpcExceptionTranslatorRegistry in ripcurl-core. Modeled after JAX-RS ExceptionMapper<E>: translators are named classes implementing the interface with a concrete exception type; the handled type is resolved reflectively via Specular's TypeRef at bean construction, so implementers write one method and never restate the type. The default registry keys translators by exact exception class and resolves at dispatch by walking the thrown exception's superclass chain. When no match is found, a built-in fallback returns -32603 Internal error with a deliberately-generic message (implementation details don't leak to clients) and logs the full exception at ERROR for operators. Applications replace the fallback by registering their own JsonRpcExceptionTranslator<Exception>. Duplicate registrations for the same type are rejected at construction.
  • Built-in translators registered as beans via ripcurl-autoconfigure, each @ConditionalOnMissingBean:
    • DefaultJsonRpcExceptionTranslator preserves a JsonRpcException's self-declared code and message.
    • IllegalArgumentExceptionTranslator maps Java's built-in "bad argument" exception to -32602 Invalid params, so handlers can throw new IllegalArgumentException(...) without knowing about JsonRpcException.
    • ParameterResolutionExceptionTranslator maps methodical's ParameterResolutionException to -32602.
  • New ripcurl-jakarta-validation module — ships ConstraintViolationExceptionTranslator which maps Jakarta Bean Validation's ConstraintViolationException to -32602 Invalid params with per-violation detail (field, message) emitted as a JSON array in the error response's data field. invalidValue is deliberately omitted to avoid leaking sensitive inputs. Spring wiring lives in ripcurl-autoconfigure as RipCurlJakartaValidationAutoConfiguration, gated by @ConditionalOnClass on both the Jakarta API and our translator class.
  • Native-image hints for the exception translator SPI and all built-in translators, so TypeRef can resolve each translator's <E> under GraalVM native-image without losing generic-signature metadata. Jakarta validation hints are registered conditionally via @ImportRuntimeHints so they only apply when the optional module is on the classpath.

Changed

  • Bumped methodical 0.3.0 → 0.5.0. Transitively pulls Specular into the classpath.
  • Dispatcher's outer catch narrowed from Throwable to Exception. JVM-fatal Errors (OOM, StackOverflow, LinkageError) now propagate unchanged — matching Spring MVC, JAX-RS, and Spring Security practice. The JsonRpcExceptionTranslator SPI bound matches (<E extends Exception>).

Migration

  • Catch-all error message is now scrubbed. Applications that relied on seeing the raw exception message in -32603 Internal error responses will now see "Internal error" instead. Server logs retain the full exception; the change specifically stops leaking implementation detail to clients. Apps that want the old behavior can register a JsonRpcExceptionTranslator<Exception> that passes exception.getMessage() through.
  • DefaultJsonRpcDispatcher gains a two-arg constructor accepting a JsonRpcExceptionTranslatorRegistry; the single-arg form still works and wires a registry populated with the built-in translators by default. No source-breaking changes.

Notes