Skip to content

Caching conflict when creating CSV schemas with different views for the same POJO #288

@mrpiggi

Description

@mrpiggi

#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.

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(...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions