Repository navigation
v3.1.0-RC1
Pre-release
Pre-release
·
14 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
https://central.sonatype.com/namespace/io.github.problem4j
- 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>
- 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) andProblemContextWebFilter(WebFlux), replacingProblemContextWebMvcFilter/ProblemContextWebFluxFilter. - Add
ProblemContextCustomizerinterfaces (for both WebMVC and WebFlux) to modifyProblemContextwithout subclassingProblemContextFilter/ProblemContextWebFilter, e.g. to add a custom request identifier. AllProblemContextCustomizerbeans are invoked in their order, as the last step of building a new context, so they may also overwritetraceIdset by the framework. In WebFlux a customizer returnsMono<Void>;ProblemContextCustomizer.sync(...)creates one from a synchronous function. - Add
ProblemResponseEntityExceptionHandler(for both WebMVC and WebFlux), replacingProblemEnhancedWebMvcHandler/ProblemEnhancedWebFluxHandler. The former classes extend the new one and are still registered by default. - Add
ProblemInspectorinterfaces to peek onProblemobjects before returning a response. AllProblemInspectorbeans are invoked, including the ones implementing deprecatedAdviceWebMvcInspector/AdviceWebFluxInspector. - Register Problem4J autoconfigurations in Spring Boot test slices:
@AutoConfigureJson,@AutoConfigureWebFluxand@AutoConfigureWebMvc, to make it possible to use@JsonTest,@WebFluxTest,@WebMvcTest,@RestClientTestand@WebClientTest. - Add
problem4j.tracing-sourceproperty deciding wheretraceIdofProblemContextcomes from.micrometerregistersMicrometerProblemContextFilter/MicrometerProblemContextWebFilter, which taketraceIdandspanIdof the current Micrometer Tracing span, falling back toproblem4j.tracing-header-nameheader or a random trace ID if no span is available.micrometerrequiresio.micrometer:micrometer-tracingon the classpath, otherwise application startup fails.simplekeeps the previous behavior (header or a random trace ID).auto(default) usesmicrometerifio.micrometer:micrometer-tracingis on the classpath, andsimpleotherwise. - Add
ProblemContextMethodArgumentResolver(for both WebMVC and WebFlux), resolving controller method arguments ofProblemContexttype without any annotation, to theProblemContextassigned to the current request byProblemContextFilter/ProblemContextWebFilter(nullif none is assigned). - Add
problem4j.extension-overrides.<name>properties for overriding extension members ofProblemresponses withDefaultProblemPostProcessor. 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 thathttp.server.requestsmetrics and spans report theexceptioninstead ofnone. Addproblem4j.observation-errorsproperty deciding which exceptions are recorded.server(default) records exceptions resulting in a 5xx response,allrecords all of them,nonedisables recording. - Add
FailureAnalyzer-s reporting startup failures caused by Problem4J configuration as a description with a suggested action, instead of a stack trace. MultipleProblemResolverbeans with equal order for the same exception class fail withDuplicateProblemResolverException, listing the conflicting beans, andproblem4j.tracing-sourcethat is not available on the classpath fails withUnavailableTracingSourceException. Both extendIllegalStateExceptionand keep their previous messages. - Add
ProblemOperationsfacade, resolving exceptions intoProblems, post-processingProblems andProblemDetails, or both at once. AProblemDetailis post-processed in place, keeping its type.
Changed
- With
io.micrometer:micrometer-tracingon the classpath,traceIdofProblemContextcomes from the current tracing span by default (problem4j.tracing-source=auto), instead of theproblem4j.tracing-header-nameheader 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'straceId. Setproblem4j.tracing-source=simpleto 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 theexceptionkey ofhttp.server.requestsmetrics and spans contains the exception class name instead ofnone. Setproblem4j.observation-errors=noneto keep the previous behavior. PostProcessorSettingsmethods now have default implementations returning no override (nullfortype,titleandinstance, empty map for extensions), so custom implementations only need to override the settings they use.ProblemContextSettings.getTracingHeaderName()now has a default implementation returningnull. 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, withPRECEDENCE(Ordered.HIGHEST_PRECEDENCE + 10) changeable withsetOrder(int). They run after Spring Boot'sServerHttpObservationFilterand before filters of the application with default order, so that exceptions thrown by those filters are rendered withtraceId. - Order of advices is declared with
@Orderon the classes, exposed asPRECEDENCEconstants, instead of@Beanmethods of the auto-configurations. Subclasses registered by the application inherit it, unless they declare their own@Order. Previously, they hadOrdered.LOWEST_PRECEDENCEby default. ExceptionWebMvcAdvice/ExceptionWebFluxAdviceresolve exceptions withProblemOperations, so they also use theProblemofProblemExceptionand the status and headers ofErrorResponseexceptions, which are otherwise handled byProblemExceptionWebMvcAdvice/ProblemExceptionWebFluxAdviceandProblemResponseEntityExceptionHandlerfirst.
Deprecated
- Deprecate
AdviceWebMvcInspectorandAdviceWebFluxInspectorin favor ofProblemInspector, which they now extend. - Deprecate
ProblemContextWebMvcFilterandProblemContextWebFluxFilterin favor ofProblemContextFilterandProblemContextWebFilter, which they now extend. - Deprecate
ProblemEnhancedWebMvcHandlerandProblemEnhancedWebFluxHandlerin favor ofProblemResponseEntityExceptionHandler, which they now extend. - Deprecate constructors of
ExceptionWebMvcAdvice/ExceptionWebFluxAdvice,ProblemExceptionWebMvcAdvice/ProblemExceptionWebFluxAdviceandProblemResponseEntityExceptionHandlertakingProblemPostProcessor(andProblemMapper,ProblemResolverStore), in favor of the ones takingProblemOperations.
Fixed
- Map
ProblemErrorControllertospring.web.error.pathof Spring Boot 4, instead of formerserver.error.path, so that a custom error path is not answered with404.