Skip to content

KAFKA-14218: Replace temp file handler with JUnit 5 @TempDir in connect tests - #23280

Open
KhyatiVaghamshi wants to merge 1 commit into
apache:trunkfrom
KhyatiVaghamshi:kafka-14218-tempdir-connect-tests
Open

KAFKA-14218: Replace temp file handler with JUnit 5 @TempDir in connect tests#23280
KhyatiVaghamshi wants to merge 1 commit into
apache:trunkfrom
KhyatiVaghamshi:kafka-14218-tempdir-connect-tests

Conversation

@KhyatiVaghamshi

Copy link
Copy Markdown

Summary

Replace File.createTempFile() with JUnit 5 @TempDir annotation in two Connect test files:

  • FileStreamSourceTaskTest.java (connect/file module)
  • FileOffsetBackingStoreTest.java (connect/runtime module)

This removes the need for manual @AfterEach cleanup methods as JUnit 5 handles temporary directory lifecycle automatically.

Changes

  • Added @TempDir private Path tempDir field to both test classes
  • Replaced File.createTempFile(...) with Files.createFile(tempDir.resolve(...)).toFile()
  • Removed @AfterEach teardown() methods that manually deleted temp files

Scope

This is a scoped PR covering 2 files as suggested in the JIRA ticket comments. Additional files can be migrated in follow-up PRs.

Test plan

  • FileStreamSourceTaskTest - all tests pass
  • FileOffsetBackingStoreTest - all tests pass
  • Verified locally with ./gradlew connect:file:test --tests FileStreamSourceTaskTest
  • Verified locally with ./gradlew connect:runtime:test --tests FileOffsetBackingStoreTest

…ct tests

Replace File.createTempFile() with JUnit 5 @tempdir annotation in
FileStreamSourceTaskTest and FileOffsetBackingStoreTest. This removes
the need for manual @AfterEach cleanup methods as JUnit 5 handles
temporary directory lifecycle automatically.

Generated-by: Claude (Anthropic)
@github-actions github-actions Bot added triage PRs from the community connect tests Test fixes (including flaky tests) small Small PRs labels Aug 26, 2026
@KhyatiVaghamshi

Copy link
Copy Markdown
Author

This addresses KAFKA-14218 with a scoped 2-file change as suggested in the ticket comments. cc @mimaison @showuon for review

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

Labels

connect small Small PRs tests Test fixes (including flaky tests) triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant