Skip to content

Setting FormattedBuilder's sourceType to record forces unnecessary method calls #4908

@apptie

Description

@apptie

When specifying record as the sourceType for FlatFileItemWriter, RecordFieldExtractor operates due to the following conditional statement.

if (this.sourceType != null && this.sourceType.isRecord()) {
	this.fieldExtractor = new RecordFieldExtractor<>(this.sourceType);
}

source code link

RecordFieldExtractor internally calls targetType.getRecordComponents() to return the record's fields as RecordComponent.
In this process, the values specified in FormattedBuilder.names() are ignored.

It was confirmed that in the existing test FlatFileItemWriterBuilderTests.testSetupFormatterLineAggregatorWithRecordItemType(), even when arbitrary values are specified through names(), RecordFieldExtractor ignores the values specified in names() and properly retrieves the record's fields.

Image Image

Therefore, if record is specified as the sourceType for FlatFileItemWriter, I think there is no need to call FormattedBuilder.names().

However, since the return type of FormattedBuilder.sourceType() is FormattedBuilder, in order to continue method chaining for FlatFileItemWriter, FormattedBuilder.fieldExtractor() or FormattedBuilder.names() must be called.

This appears to be an unnecessary process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions