-
-
Notifications
You must be signed in to change notification settings - Fork 151
Closed
Description
#195 added csv schema creation with views. Using the same CsvMapper with the same POJO for different views leads to unexpected results as the used view is not considered when a schema is loaded from cache as it was registered for the pojoType. Obviously, the used view should be part of the key for the cache maps _untypedSchemas and _typedSchemas.
jackson-dataformats-text/csv/src/main/java/com/fasterxml/jackson/dataformat/csv/CsvMapper.java
Lines 425 to 433 in 1202fec
| protected CsvSchema _schemaFor(JavaType pojoType, LRUMap<JavaType,CsvSchema> schemas, | |
| boolean typed, Class<?> view) | |
| { | |
| synchronized (schemas) { | |
| CsvSchema s = schemas.get(pojoType); | |
| if (s != null) { | |
| return s; | |
| } | |
| } |
Edit: A workaround is quite simple. In order to clear the cache, just use csvmapper.copy().schemaForWithView(...) instead of csvmapper.schemaForWithView(...).