Skip to content

Backwards incompatibility in 2.5.6 #3871

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

Closed
sjerman opened this issue Nov 3, 2021 · 4 comments
Closed

Backwards incompatibility in 2.5.6 #3871

sjerman opened this issue Nov 3, 2021 · 4 comments
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@sjerman
Copy link

sjerman commented Nov 3, 2021

Hi Folks,

Trying to bring our application forward to 2.5.6 and am running into an issue with @query.

Had same issue last time I did the migration - #3401 .. maybe the fix didn't make it to 2.5

The query was:

  @Query(
      " ?#{ hasRole('ROLE_ADMIN') or global.getProperty('user.global') == 'true' ? {'_class': { '$eq' : 'com.kloudspot.jamesons.datamodel.domain.location.Region' }} : { '$and' : { {'_class': { '$eq' : 'com.kloudspot.jamesons.datamodel.domain.location.Region' }}, {'$or': { { 'users._id': global.getOid( principal.id ) },{'usersFromHierarchy._id': global.getOid( principal.id ) } } } } } } ")
  @Cacheable(value = "siteRegions", keyGenerator = "siteKeyGenerator")
  List<Region> findRegions();

Get this error:

org.bson.BsonInvalidOperationException: readStartDocument can only be called when CurrentBSONType is DOCUMENT, not when CurrentBSONType is UNDEFINED.
	at org.bson.AbstractBsonReader.verifyBSONType(AbstractBsonReader.java:690)
	at org.bson.AbstractBsonReader.checkPreconditions(AbstractBsonReader.java:722)
	at org.bson.AbstractBsonReader.readStartDocument(AbstractBsonReader.java:450)
	at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.decode(ParameterBindingDocumentCodec.java:223)
	at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.captureExpressionDependencies(ParameterBindingDocumentCodec.java:202)
	at org.springframework.data.mongodb.repository.query.StringBasedMongoQuery.getBindingContext(StringBasedMongoQuery.java:136)
	at org.springframework.data.mongodb.repository.query.StringBasedMongoQuery.createQuery(StringBasedMongoQuery.java:121)
	at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.doExecute(AbstractMongoQuery.java:122)
	at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.execute(AbstractMongoQuery.java:107)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy72.findByName(Unknown Source)
	at com.example.demo.RepoTests.testOne(RepoTests.java:40)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at 
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 3, 2021
@christophstrobl
Copy link
Member

If you are referring to Spring Boot 2.5.6, using Data MongoDB 3.2.6, then the fix for #3401 is in.

@sjerman
Copy link
Author

sjerman commented Nov 3, 2021

Yes. Those are the versions ... I have a test project that is 'stock' 2.5.6/3.2.6 giving that error. I'll do a few more checks.. just in case. Shall I upload the test project?

@sjerman
Copy link
Author

sjerman commented Nov 3, 2021

Looking at the code it is parsing the BSON before any SPEL processing.... I guess that is the issue.

Demo project showing issue is attached. (run RepoTests junit)

issue.zip

@christophstrobl
Copy link
Member

thanks for the reproducer - we'll have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
3 participants