Skip to content

fix: copy default read converter map to isolate per-reader custom converters - #972

Open
Aias00 wants to merge 4 commits into
apache:mainfrom
Aias00:fix/read-converter-isolation-971
Open

fix: copy default read converter map to isolate per-reader custom converters#972
Aias00 wants to merge 4 commits into
apache:mainfrom
Aias00:fix/read-converter-isolation-971

Conversation

@Aias00

@Aias00 Aias00 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

Fixes #971.

The workbook-level read holder aliased DefaultConverterLoader's shared static allConverter map instead of copying it, so custom converters registered via registerConverter(...) were put() into the global map and leaked into every later, unrelated read on the same JVM. This mirrors the write side (AbstractWriteHolder:271), which already copies.

Root cause

AbstractReadHolder:

if (parentAbstractReadHolder == null) {
    setConverterMap(DefaultConverterLoader.loadDefaultReadConverter()); // shared static, no copy
} else {
    setConverterMap(new HashMap<>(parentAbstractReadHolder.getConverterMap()));
}

loadDefaultReadConverter() returns the static allConverter map by reference, so the getConverterMap().put(...) loop right below mutates the shared map and the registration survives the reader.

Fix

setConverterMap(new HashMap<>(DefaultConverterLoader.loadDefaultReadConverter()));

Verification

Added ReadConverterIsolationTest which:

  1. reads a file with a registered marker converter → values carry the marker (expected);
  2. reads the same file with a fresh reader and no converter → asserts values carry no marker.

Before the fix, step 2 failed (hello [MARKER] instead of hello). After the fix it passes. Full fesod-sheet suite: Tests run: 668, Failures: 0, Errors: 0.

…verters (apache#971)

The workbook-level read holder aliased DefaultConverterLoader's shared static
allConverter map instead of copying it, so custom converters registered via
registerConverter() were put() into the global map and leaked into every later,
unrelated read on the same JVM. Mirror the write side (AbstractWriteHolder:271),
which already copies, and add a regression test.
Copilot AI review requested due to automatic review settings July 27, 2026 13:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Aias00
Aias00 force-pushed the fix/read-converter-isolation-971 branch from a2c6303 to b36f79f Compare July 27, 2026 13:36
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] Read-side custom converter leaks into the shared global converter map

2 participants