Skip to content

Fix MappingElasticsearchConverter memory leak. #1928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class MappingElasticsearchConverter
private final GenericConversionService conversionService;
// don't access directly, use getConversions(). to prevent null access
private CustomConversions conversions = new ElasticsearchCustomConversions(Collections.emptyList());
private final SpELContext spELContext = new SpELContext(new MapAccessor());
private final EntityInstantiators instantiators = new EntityInstantiators();

public MappingElasticsearchConverter(
MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
Expand Down Expand Up @@ -159,7 +161,7 @@ public void afterPropertiesSet() {
@Override
public <R> R read(Class<R> type, Document source) {

Reader reader = new Reader(mappingContext, conversionService, getConversions());
Reader reader = new Reader(mappingContext, conversionService, getConversions(), spELContext, instantiators);
return reader.read(type, source);
}

Expand Down Expand Up @@ -200,14 +202,16 @@ private Base(
private static class Reader extends Base {

private final SpELContext spELContext;
private final EntityInstantiators instantiators = new EntityInstantiators();
private final EntityInstantiators instantiators;

public Reader(
MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext,
GenericConversionService conversionService, CustomConversions conversions) {
GenericConversionService conversionService, CustomConversions conversions, SpELContext spELContext,
EntityInstantiators instantiators) {

super(mappingContext, conversionService, conversions);
this.spELContext = new SpELContext(new MapAccessor());
this.spELContext = spELContext;
this.instantiators = instantiators;
}

@SuppressWarnings("unchecked")
Expand Down