Skip to content

fix: resolve header cells against the built-in read converters (#1098) - #1212

Open
Mikkey-f wants to merge 2 commits into
apache:mainfrom
Mikkey-f:fix/1098-header-converter-leak
Open

Mikkey-f wants to merge 2 commits into
apache:mainfrom
Mikkey-f:fix/1098-header-converter-leak

Conversation

@Mikkey-f

Copy link
Copy Markdown
Contributor

Fixes #1098

What changes were proposed in this pull request?

ConverterUtils.convertToStringMap turns header cells into strings for two consumers: the name matching in DefaultAnalysisEventProcessor.buildHead and the map handed to AnalysisEventListener.invokeHeadMap. It resolved the converter through the holder's converter map, which also carries user registrations — so a user-registered Converter<String> was applied to the header text itself: the header flag became FLAG, @ExcelProperty("flag") no longer matched, and the field was left null with no exception. The data cell was not converted either.

The lookup now uses the built-in read converters (DefaultConverterLoader.loadDefaultReadConverter()) only. Data cells are still resolved with user converters through convertToJavaObject; the write path is untouched.

Why

Impact

How was this patch tested?

New HeaderConverterIsolationTest (3 tests):

  • explicit STRING-key converter: name matching still works and the data cell is converted (red before the fix: the field was null);
  • invokeHeadMap receives the raw header text (red before the fix: FLAG instead of flag);
  • wildcard converter: the header stays raw and name matching keeps working.

ConverterUtilsTest is updated to the new contract: the convertToStringMap tests now assert that a user registration in the holder's map is not consulted (the mock converter is never invoked), and the missing-converter case uses DATE, which genuinely has no built-in (String, DATE) converter (BOOLEAN does, so it no longer exercised that path).

Red/green verified: both failing cases were reproduced against the pre-fix code, then turned green. Full suite: 1047/1047 green; spotless and javadoc pass.

Notes

…e#1098)

ConverterUtils.convertToStringMap resolved the converter for header cells through the
holder's converter map, which also carries user registrations, so a user-registered
Converter<String> rewrote the header text itself: "flag" became "FLAG",
@ExcelProperty name matching failed, and the field was silently left null (the data
cell was not converted either). The header path now uses the built-in read converters
only; the data-cell path is untouched.

ConverterUtilsTest is updated to the new contract: the convertToStringMap tests now
assert that a user registration under the same key is not consulted, and the
missing-converter case uses DATE, which has no built-in (String, DATE) converter
(BOOLEAN does).

invokeHeadMap now receives the raw header map, as settled in apache#1098.

This branch has not been deployed

No deployments
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.

[Bug] Header cells are converted with user-registered String converters, breaking @ExcelProperty(name) matching

1 participant