DATACMNS-1743 - Fix lazy repository lookups in DomainClassConverter.

We now eagerly register DomainClassConverter as converter with the ConversionService in the web setup. We also refrain from explicitly registering the traget converters with the ConversionService as that might trigger a ConcurrentModificationException if called during an iteration over the converters in the first place. As DomainClassConverter registers itself for all ConvertiblePairs and delegates to the individual converters anyway.
This commit is contained in:
Oliver Drotbohm
2020-06-15 22:09:39 +02:00
parent f93a66fdbc
commit 9c50f86061
2 changed files with 12 additions and 3 deletions

View File

@@ -62,6 +62,7 @@ public class DomainClassConverter<T extends ConversionService & ConverterRegistr
Assert.notNull(conversionService, "ConversionService must not be null!");
this.conversionService = conversionService;
this.conversionService.addConverter(this);
}
/*
@@ -112,10 +113,7 @@ public class DomainClassConverter<T extends ConversionService & ConverterRegistr
Repositories repositories = new Repositories(context);
this.toEntityConverter = Optional.of(new ToEntityConverter(repositories, conversionService));
this.toEntityConverter.ifPresent(it -> conversionService.addConverter(it));
this.toIdConverter = Optional.of(new ToIdConverter(repositories, conversionService));
this.toIdConverter.ifPresent(it -> conversionService.addConverter(it));
return repositories;
});