Class ErrorEnvironmentPostProcessor

java.lang.Object
com.broadleafcommerce.common.error.validation.web.autoconfigure.ErrorEnvironmentPostProcessor
All Implemented Interfaces:
org.springframework.boot.env.EnvironmentPostProcessor, org.springframework.core.Ordered

public class ErrorEnvironmentPostProcessor extends Object implements org.springframework.boot.env.EnvironmentPostProcessor, org.springframework.core.Ordered
Default property overrides for the error common library.

Spring Boot 4 defaults the web message converters and reactive codecs to Jackson 3, while Broadleaf standardizes on Jackson 2. The spring.http...preferred-json-mapper=jackson2 defaults are normally supplied to most modules by broadleaf-common-extension; this library does not depend on it, so it ships the same defaults here to remain self-sufficient (e.g. when used standalone or exercised by its own slice tests).

These defaults only apply under Spring Boot 4, where the JACKSON2 preferred-json-mapper value (and spring.jackson.use-jackson2-defaults) exist and Jackson 3 is the default. Under Spring Boot 3.5 the JsonMapper enum has no JACKSON2 constant (Jackson 2 is already the default), so applying preferred-json-mapper=jackson2 would fail condition evaluation with No enum constant ... JACKSON2. The defaults are therefore skipped on 3.5, keeping this library dual-compatible across both Boot lines.

Author:
Jeff Fischer
  • Constructor Details

    • ErrorEnvironmentPostProcessor

      public ErrorEnvironmentPostProcessor()
  • Method Details

    • postProcessEnvironment

      public void postProcessEnvironment(org.springframework.core.env.ConfigurableEnvironment environment, org.springframework.boot.SpringApplication application)
      Specified by:
      postProcessEnvironment in interface org.springframework.boot.env.EnvironmentPostProcessor
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • supportsJackson2PreferredMapper

      protected boolean supportsJackson2PreferredMapper()
      Whether the running Spring Boot version supports the jackson2 preferred-json-mapper value. True on Boot 4.x (where Jackson 3 is the default and Jackson 2 must be explicitly preferred); false on Boot 3.5, whose JsonMapper enum has no JACKSON2 constant (Jackson 2 is already the default, so the preferred-json-mapper value is unnecessary and would fail condition evaluation).