-
Notifications
You must be signed in to change notification settings - Fork 487
Different default converters in 3.3 breaks existing code #1101
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
Comments
To work around this I tried to use I COULD of course write my own |
More of a workaround, but you can use private static ConverterManager createDefaultConverterManager() {
GenericConversionService conversionService = new GenericConversionService();
ConverterUtils.addDefaultConverters(conversionService);
return new ConversionServiceConverterManager(conversionService);
} You then need to provide your own converters, but converting a string to int/long and vice versa is trivial. Here's an example from my (Kotlin) codebase (using @Bean
fun objectDirectoryMapper() = DefaultObjectDirectoryMapper().apply {
val conversionService = DefaultConversionService()
ConverterUtils.addDefaultConverters(conversionService)
this.setConversionService(conversionService)
}
@Bean
fun ldapTemplate(
contextSource: ContextSource,
objectDirectoryMapper: ObjectDirectoryMapper
) = LdapTemplate(contextSource).apply {
setIgnorePartialResultException(true)
this.objectDirectoryMapper = objectDirectoryMapper
} |
Well, as I said, my workaround was even easier (more or less the same as yours): public class LdapConversionService extends DefaultConversionService {
public LdapConversionService() {
ConverterUtils.addDefaultConverters(this);
}
} but I am still not convinced... |
Uh oh!
There was an error while loading. Please reload this page.
I just switched from Version 3.2.12 to 3.3.0 and it broke my code, I got:
org.springframework.ldap.odm.core.impl.InvalidEntryException: Missing converter from class java.lang.String to class java.lang.Long, this is needed for field xxx on Entry class Yyy
.The reason seems to be different default converters are used now:
spring-ldap/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java
Line 81 in 84f6432
is creating a
org.springframework.core.convert.support.GenericConversionService
whereas it used to be aorg.springframework.core.convert.support.DefaultConversionService
which actually CAN convertString
toLong
.The text was updated successfully, but these errors were encountered: