Skip to content

Fix: FlatFileItemWriterBuilder - Ensure names() is respected for RecordFieldExtractor #4936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DevSeongmin
Copy link

Description
When using FlatFileItemWriterBuilder with Java Record types, specifying .names() is currently required, but RecordFieldExtractor ignores those names due to a missing .setNames() call. This causes all record components to be extracted regardless of the .names() setting, leading to unexpected behavior.

This patch fixes the issue by invoking .setNames() on RecordFieldExtractor when names are specified, aligning its behavior with BeanWrapperFieldExtractor used for non-record types.

No breaking changes are introduced.

Changes
Added .setNames() call on newly created RecordFieldExtractor if names are provided.

Maintains consistency and backward compatibility in builder API.

Motivation
Enables partial field extraction from Java Records via .names() method, matching the behavior for Java Beans.

Resolves a long-standing inconsistency and confusion reported by users and educators.

Additional Notes
Powerd by KILL-9 💀

Related Issue
This PR addresses issue #4935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant