Closed spring-projects-issues closed 5 years ago
Michael Simons commented
How to you register your custom converter?
Michael Simons commented
Also: Are you running this in Spring Boot or plain Spring? If the last one is the case, could you maybe provide an example using the templates? https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template
Torsten Kuhnhenne commented
Via an annotation in a domain class:
@Property
@Convert(Neo4jOAuth2RefreshTokenToStringConverter.class)
private OAuth2RefreshToken oAuth2RefreshToken;
The class is annotated with @NodeEntity
Torsten Kuhnhenne commented
It`s a plain Spring project
Michael Simons commented
Thanks, that helps. Can now reproduce the behavior
Michael Simons commented
Thanks again for bringing this to our attention.
Your code broke because we fixed an issue with the MetaDataDrivenConversionService
. It hasn't been correctly initialized before (actually, in your case probably not at all, however, converters should have been applied nevertheless. I'd be happy if you can check this).
That error has been fixed.
Which led now to another error in MetaDataDrivenConversionService
which we are fixing in the next service release of Lovelace
Michael Simons commented
This is fixed and also back ported to 5.0.11. If you want to try out your project with the fixed version of Lovelace until it's release, Torsten Kuhnhenne please use this version
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>5.1.1.BUILD-SNAPSHOT</version>
</dependency>
Edit: Sorry, I give up on the formatting of this answer. Snapshot repositories is under https://repo.spring.io/snapshot
Torsten Kuhnhenne commented
Michael Simons: Thanks a lot for the quick reply and fix! The snapshot version works for me :)
In response to your comment:
In 5.0.10 the converters are applied. Or should I check if the MetaDataDrivenConversionService
is initialized or not?
Michael Simons commented
Thanks for your feedback!
In 5.0.10 the converters are applied. Or should I check if the MetaDataDrivenConversionService is initialized or not?
The later. I'd guess your converters are applied through other means in SDN
Torsten Kuhnhenne commented
You are right, the constructor of the class MetaDataDrivenConversionService
is never called when i start my application with SDN 5.0.10.
Maybe the converters are applied through the OGM?
Michael Simons commented
Thanks for baring with me.
The MetaDataDrivenConversionService
has been laying around basically unused in SDN 5.0.x. There are tests that verifies its integration with existing Spring Converters.
Converters on properties have been applied directly.
As you might have read in the release notes, we support non-default constructors with SDN 5.1. To make this as smooth as possible, we also want to have converters in place and use existing Spring converters if possible. If there are non at all or not a unique one, we now make use of our own.
In your SDN 5.1.x without Boot, there is no preexisting Conversion Service, so we eagerly instantiated the MetaDataDrivenConversionService
which lead to the discovery of your error.
In short: Your application worked as expected.
Torsten Kuhnhenne opened DATAGRAPH-1131 and commented
When i use an abstract base class for an
AttributeConverter
with specific implementations i got an ArrayIndexOutOfBoundsException in MetaDataDrivenConversionService at line #77 when the converter is registered.The same code works with SDN 5.0.10. I didn't find any differences in
MetaDataDrivenConversionService
between 5.0.10 and 5.1.0, so i have no idea why it doesn't work in 5.1.0.Base class for the converter:
The implementation class:
When i add an additional
implements AttributeConverter<OAuth2RefreshToken,String>
to the implementation class everythings works as excepected.Stacktrace:
Affects: 5.1 GA (Lovelace)
Backported to: 5.1.1 (Lovelace SR1), 5.0.11 (Kay SR11)