Skip to content

Remove unnecessary generic from JobKeyGenerator interface #4886

@patrickwinti

Description

@patrickwinti

The JobKeyGenerator<T> interface currently uses a generic type parameter <T> to represent the source used to generate a job key. However, in practice, the implementations and usages of this interface rely on JobParameters as the source type.

Since the generic parameter is not providing meaningful flexibility and introduces unnecessary complexity (e.g., requiring casts or wildcard types in consumers), it would be cleaner to refactor the interface to:

public interface JobKeyGenerator {
    String generateKey(JobParameters source);
}

Activity

fmbenhassine

fmbenhassine commented on Jul 14, 2025

@fmbenhassine
Contributor

I agree, thank you for raising this!

This is a good candidate for a major release so I will plan it for v6.

added this to the 6.0.0-M1 milestone on Jul 14, 2025
fmbenhassine

fmbenhassine commented on Jul 14, 2025

@fmbenhassine
Contributor

Resolved with #4887.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @fmbenhassine@patrickwinti

      Issue actions

        Remove unnecessary generic from JobKeyGenerator interface · Issue #4886 · spring-projects/spring-batch