Temporal Jackson 3 Payload Converter (SL028)

Verifies services using the Temporal Spring Boot starter force Temporal to use Jackson 3.

Description

Checks the effective POM of every module for a dependency on 'io.temporal:temporal-spring-boot-starter'. When the starter is present, the class annotated with @SpringBootApplication must call JacksonJsonPayloadConverter.setDefaultAsJackson3(true, true) before SpringApplication.run(…​), so the Temporal SDK serializes payloads with Jackson 3 instead of its Jackson 2 default.

Rationale

Temporal defaults to Jackson 2 payload conversion. Without the explicit opt-in, workflow and activity payloads serialize differently from the rest of the service, which only surfaces at runtime.

Findings

  • ERROR

    • Temporal Spring Boot starter dependency present but no @SpringBootApplication class found

    • JacksonJsonPayloadConverter.setDefaultAsJackson3 missing from the @SpringBootApplication class

    • JacksonJsonPayloadConverter.setDefaultAsJackson3 called with arguments other than (true, true)

    • JacksonJsonPayloadConverter.setDefaultAsJackson3 called after SpringApplication.run(…​)

Noncompliant

Temporal service missing the Jackson 3 opt-in
// SL028 noncompliant Application: no Jackson 3 opt-in at all
@SpringBootApplication
public class Application {

    public static void main(final String[] args) {
        // Temporal keeps its Jackson 2 payload converter at runtime.
        SpringApplication.run(Application.class, args);
    }
}
Temporal service explicitly staying on Jackson 2
// SL028 noncompliant Application: explicitly keeps Temporal on Jackson 2
@SpringBootApplication
public class Application {

    public static void main(final String[] args) {
        // Opting out is still a violation; the arguments must be (true, true).
        JacksonJsonPayloadConverter.setDefaultAsJackson3(false, false);
        SpringApplication.run(Application.class, args);
    }
}

Compliant

Temporal service forcing Jackson 3
// SL028 compliant Application: forces Temporal to use Jackson 3
@SpringBootApplication
public class Application {

    public static void main(final String[] args) {
        // Force Temporal to use Jackson 3
        JacksonJsonPayloadConverter.setDefaultAsJackson3(true, true);
        SpringApplication.run(Application.class, args);
    }
}

Configuration

This rule has no configuration.