Status

Current stateDraft

Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]

JIRA: KAFKA-20297

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

The Time interface and Timer class in org.apache.kafka.common.utils are currently exposed through public APIs but not officially designated as public. Following KIP-1247 (Make Bytes public), these should be made officially public.

However, KafkaStreams exposes constructors accepting Time parameters that are only useful for testing, not production use. As noted in the KIP-1247 discussion, these test-only constructors should be deprecated before making Time the official public API.

Public Interfaces

New public APIs (4.4):

Deprecated (4.4, removed in 5.0):

These are only used for testing and pollute the public API.

Proposed Changes

Make Time and Timer officially public (4.4):

Include Time and Timer in public API Javadocs with enhanced documentation.

Deprecate KafkaStreams test constructors (4.4):

Deprecate the following constructors (removal in 5.0):

Provide Test Utility (4.4):

Create org.apache.kafka.streams.test.KafkaStreamsMock with static factory methods for creating KafkaStreams instances with custom Time implementations.

Example:

MockTime mockTime = new MockTime();
KafkaStreams streams = KafkaStreamsMock.create(topology, props, mockTime);

Compatibility, Deprecation, and Migration Plan

Test migration:

// Before
KafkaStreams streams = new KafkaStreams(topology, props, mockTime);

// After
KafkaStreams streams = KafkaStreamsMock.create(topology, props, mockTime);

No changes required for production code.

Test Plan

This KIP primarily involves API designation and deprecation rather than functional changes. Testing will focus on:

No new system tests required. Time and Timer functionality remains unchanged, only their API designation and test access patterns are updated.

Rejected Alternatives

Keep test constructors public: Continues to pollute the public API with test-only functionality.