spring-projects / spring-data-neo4j

Provide support to increase developer productivity in Java when using Neo4j. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
http://spring.io/projects/spring-data-neo4j
Apache License 2.0
838 stars 618 forks source link

Unable to persist objects which contain a string that has JSON reserved or restricted characters [DATAGRAPH-1052] #1616

Closed spring-projects-issues closed 6 years ago

spring-projects-issues commented 7 years ago

Ranajyoti Chakraborti opened DATAGRAPH-1052 and commented

If any Node Entity contains a string field which gets populated by a string like this

Céline Marie Claudette Dion, CC OQ ChLD is a Canadian singer and businesswoman. Born into a large family from Charlemagne, Quebec, Dion emerged as a teen star in the French-speaking world after her manager and future husband René Angélil mortgaged his home to finance her first record.

upon trying to save this entity it will throw a JSON parser exception. To avoid this exception I have to encode the string for JSON compatible format. This should be done automatically by SDN.

java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x6c
 at [Source: [B@6a905457; line: 1, column: 69]
    at org.neo4j.ogm.drivers.bolt.request.BoltRequest.executeRequest(BoltRequest.java:175)
    at org.neo4j.ogm.drivers.bolt.request.BoltRequest.execute(BoltRequest.java:89)
    at org.neo4j.ogm.session.request.RequestExecutor.executeSave(RequestExecutor.java:289)
    at org.neo4j.ogm.session.request.RequestExecutor.executeSave(RequestExecutor.java:68)
    at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:85)
    at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:44)
    at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:447)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.data.neo4j.transaction.SharedSessionCreator$SharedSessionInvocationHandler.invoke(SharedSessionCreator.java:131)
    at com.sun.proxy.$Proxy88.save(Unknown Source)
    at org.springframework.data.neo4j.repository.support.SimpleNeo4jRepository.save(SimpleNeo4jRepository.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:504)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:489)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy107.save(Unknown Source)

Affects: 4.2.8 (Ingalls SR8)

spring-projects-issues commented 7 years ago

Gerrit Meier commented

Thanks for reporting the issue. I tried to reproduce it with a simple sample and the text you provided but did not get the exception you got above. Tested with neo4j-3.1, 3.2 and 3.3 on Mac, 3.2 on Windows10. Is there any logic how the string gets into the node? I just set it, so maybe some pre-processing does create the problem

spring-projects-issues commented 6 years ago

Nicolas Mervaillie commented

Unable to reproduce. Closing. Feel free to reopen with more details and a test case if still a problem.