Aias00 opened a new issue, #971: URL: https://github.com/apache/fesod/issues/971
### Search before asking - [x] I searched in the [issues](https://github.com/apache/fesod/issues) and found nothing similar. ### Fesod version current main (1f03942) ### JDK version Temurin 25 (code path is version-independent, affects 8+) ### Operating system Linux (not OS-specific) ### Steps To Reproduce A converter registered on one `ExcelReader` permanently pollutes the process-wide default converter registry, so a later, unrelated read (with no converter registered) still applies it. ```java @Data public class StringRow { @ExcelProperty("value") private String value; } // A converter that appends a marker so leakage is observable. public class MarkerConverter implements Converter<String> { @Override public Class<?> supportJavaTypeKey() { return String.class; } @Override public CellDataTypeEnum supportExcelTypeKey() { return CellDataTypeEnum.STRING; } @Override public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty p, GlobalConfiguration g) { return cellData.getStringValue() + " [MARKER]"; } @Override public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty p, GlobalConfiguration g) { return new WriteCellData<>(value); } } File file = ...; // an xlsx whose single data cell holds "hello" // First read: register the marker converter. List<StringRow> first = new ArrayList<>(); FesodSheet.read(file, StringRow.class, new PageReadListener<>(first::addAll)) .registerConverter(new MarkerConverter()) .sheet().doRead(); // Second read: fresh reader, NO converter registered. List<StringRow> second = new ArrayList<>(); FesodSheet.read(file, StringRow.class, new PageReadListener<>(second::addAll)) .sheet().doRead(); ``` ### Current Behavior `first` correctly contains `hello [MARKER]`, but `second` also contains `hello [MARKER]` — the converter registered only on the first read is still applied. ### Expected Behavior `second` should contain `hello` (no marker). A converter registered on one reader must not affect any other reader. ### Anything else? Root cause: the workbook-level read holder aliases the shared static default converter map instead of copying it: https://github.com/apache/fesod/blob/main/fesod-sheet/src/main/java/org/apache/fesod/sheet/read/metadata/holder/AbstractReadHolder.java#L122-L126 ```java if (parentAbstractReadHolder == null) { setConverterMap(DefaultConverterLoader.loadDefaultReadConverter()); // shared static map, no copy } else { setConverterMap(new HashMap<>(parentAbstractReadHolder.getConverterMap())); } ``` `DefaultConverterLoader.loadDefaultReadConverter()` returns the static `allConverter` map by reference. The block immediately below then does `getConverterMap().put(...)` for each registered custom converter, mutating that shared static map, so the registration survives the reader and leaks into every later read on the same JVM. The write side already handles this correctly by copying (`AbstractWriteHolder.java:271`): ```java setConverterMap(new HashMap<>(DefaultConverterLoader.loadDefaultWriteConverter())); ``` Doing the same on the read side fixes it: ```java setConverterMap(new HashMap<>(DefaultConverterLoader.loadDefaultReadConverter())); ``` ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
