Skip to content

v3.1.0-RC1

Pre-release
Pre-release

Choose a tag to compare

@damianmalczewski damianmalczewski released this 15 Nov 15:57
· 14 commits to main since this release
Immutable release. Only release title and notes can be modified.
2486fb9

Spring Boot

https://central.sonatype.com/namespace/io.github.problem4j

  1. Maven:
    <dependencies>
        <!-- pick one for your project -->
        <dependency>
            <groupId>io.github.problem4j</groupId>
            <artifactId>problem4j-spring-webflux</artifactId>
            <version>3.1.0-RC1</version>
        </dependency>
        <dependency>
            <groupId>io.github.problem4j</groupId>
            <artifactId>problem4j-spring-webmvc</artifactId>
            <version>3.1.0-RC1</version>
        </dependency>
    </dependencies>
  2. Gradle (Kotlin DSL):
    dependencies {
        // pick one for  your project
        implementation("io.github.problem4j:problem4j-spring-webflux:3.1.0-RC1")
        implementation("io.github.problem4j:problem4j-spring-webmvc:3.1.0-RC1")
    }

Added

  • Add ProblemContextFilter (WebMVC) and ProblemContextWebFilter (WebFlux), replacing ProblemContextWebMvcFilter / ProblemContextWebFluxFilter.
  • Add ProblemContextCustomizer interfaces (for both WebMVC and WebFlux) to modify ProblemContext without subclassing ProblemContextFilter / ProblemContextWebFilter, e.g. to add a custom request identifier. All ProblemContextCustomizer beans are invoked in their order, as the last step of building a new context, so they may also overwrite traceId set by the framework. In WebFlux a customizer returns Mono<Void>; ProblemContextCustomizer.sync(...) creates one from a synchronous function.
  • Add ProblemResponseEntityExceptionHandler (for both WebMVC and WebFlux), replacing ProblemEnhancedWebMvcHandler / ProblemEnhancedWebFluxHandler. The former classes extend the new one and are still registered by default.
  • Add ProblemInspector interfaces to peek on Problem objects before returning a response. All ProblemInspector beans are invoked, including the ones implementing deprecated AdviceWebMvcInspector / AdviceWebFluxInspector.
  • Register Problem4J autoconfigurations in Spring Boot test slices: @AutoConfigureJson, @AutoConfigureWebFlux and @AutoConfigureWebMvc, to make it possible to use @JsonTest, @WebFluxTest, @WebMvcTest, @RestClientTest and @WebClientTest.
  • Add problem4j.tracing-source property deciding where traceId of ProblemContext comes from. micrometer registers MicrometerProblemContextFilter / MicrometerProblemContextWebFilter, which take traceId and spanId of the current Micrometer Tracing span, falling back to problem4j.tracing-header-name header or a random trace ID if no span is available. micrometer requires io.micrometer:micrometer-tracing on the classpath, otherwise application startup fails. simple keeps the previous behavior (header or a random trace ID). auto (default) uses micrometer if io.micrometer:micrometer-tracing is on the classpath, and simple otherwise.
  • Add ProblemContextMethodArgumentResolver (for both WebMVC and WebFlux), resolving controller method arguments of ProblemContext type without any annotation, to the ProblemContext assigned to the current request by ProblemContextFilter / ProblemContextWebFilter (null if none is assigned).
  • Add problem4j.extension-overrides.<name> properties for overriding extension members of Problem responses with DefaultProblemPostProcessor. Templates may use {problem.type}, {problem.title}, {problem.status}, {problem.detail}, {problem.instance} and {context.<key>} placeholders. An override replaces an existing extension with the same name and is skipped if any placeholder cannot be resolved. A template made of exactly one placeholder keeps the type of the resolved value (e.g. {problem.status} is a number).
  • Add ObservationErrorProblemInspector (for both WebMVC and WebFlux), recording exceptions handled by Problem4J as errors of the current HTTP server observation (ServerRequestObservationContext), so that http.server.requests metrics and spans report the exception instead of none. Add problem4j.observation-errors property deciding which exceptions are recorded. server (default) records exceptions resulting in a 5xx response, all records all of them, none disables recording.
  • Add FailureAnalyzer-s reporting startup failures caused by Problem4J configuration as a description with a suggested action, instead of a stack trace. Multiple ProblemResolver beans with equal order for the same exception class fail with DuplicateProblemResolverException, listing the conflicting beans, and problem4j.tracing-source that is not available on the classpath fails with UnavailableTracingSourceException. Both extend IllegalStateException and keep their previous messages.
  • Add ProblemOperations facade, resolving exceptions into Problems, post-processing Problems and ProblemDetails, or both at once. A ProblemDetail is post-processed in place, keeping its type.

Changed

  • With io.micrometer:micrometer-tracing on the classpath, traceId of ProblemContext comes from the current tracing span by default (problem4j.tracing-source=auto), instead of the problem4j.tracing-header-name header or a random trace ID. The header value is used only if no span is available, and the header is still written into responses with the span's traceId. Set problem4j.tracing-source=simple to keep the previous behavior.
  • Exceptions handled by Problem4J resulting in a 5xx response are recorded as errors of the current HTTP server observation by default (problem4j.observation-errors=server), so the exception key of http.server.requests metrics and spans contains the exception class name instead of none. Set problem4j.observation-errors=none to keep the previous behavior.
  • PostProcessorSettings methods now have default implementations returning no override (null for type, title and instance, empty map for extensions), so custom implementations only need to override the settings they use.
  • ProblemContextSettings.getTracingHeaderName() now has a default implementation returning null. As the interface no longer has an abstract method, it can't be implemented with a lambda anymore - use an anonymous class instead.
  • Filters implement Ordered, with PRECEDENCE (Ordered.HIGHEST_PRECEDENCE + 10) changeable with setOrder(int). They run after Spring Boot's ServerHttpObservationFilter and before filters of the application with default order, so that exceptions thrown by those filters are rendered with traceId.
  • Order of advices is declared with @Order on the classes, exposed as PRECEDENCE constants, instead of @Bean methods of the auto-configurations. Subclasses registered by the application inherit it, unless they declare their own @Order. Previously, they had Ordered.LOWEST_PRECEDENCE by default.
  • ExceptionWebMvcAdvice / ExceptionWebFluxAdvice resolve exceptions with ProblemOperations, so they also use the Problem of ProblemException and the status and headers of ErrorResponse exceptions, which are otherwise handled by ProblemExceptionWebMvcAdvice / ProblemExceptionWebFluxAdvice and ProblemResponseEntityExceptionHandler first.

Deprecated

  • Deprecate AdviceWebMvcInspector and AdviceWebFluxInspector in favor of ProblemInspector, which they now extend.
  • Deprecate ProblemContextWebMvcFilter and ProblemContextWebFluxFilter in favor of ProblemContextFilter and ProblemContextWebFilter, which they now extend.
  • Deprecate ProblemEnhancedWebMvcHandler and ProblemEnhancedWebFluxHandler in favor of ProblemResponseEntityExceptionHandler, which they now extend.
  • Deprecate constructors of ExceptionWebMvcAdvice / ExceptionWebFluxAdvice, ProblemExceptionWebMvcAdvice / ProblemExceptionWebFluxAdvice and ProblemResponseEntityExceptionHandler taking ProblemPostProcessor (and ProblemMapper, ProblemResolverStore), in favor of the ones taking ProblemOperations.

Fixed

  • Map ProblemErrorController to spring.web.error.path of Spring Boot 4, instead of former server.error.path, so that a custom error path is not answered with 404.