Skip to content
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

Nested Interface-based projection fails with ConverterNotFoundException #4609

Closed
ELMORABITYounes opened this issue Jan 11, 2024 · 3 comments
Closed
Assignees
Labels
type: bug A general bug

Comments

@ELMORABITYounes
Copy link

ELMORABITYounes commented Jan 11, 2024

Starting from spring-data-mongodb 3.4.3 (spring boot 2.7.4) when trying to use interface-based recusive projeection as described here, a ConverterNotFoundException is thrown (see example below).

You can find here a simple project for reproducing the issue.

Note that the issue is only reproducible when using reactive repositories and not when using blocking repositories.

Example:

java.lang.AssertionError: expectation "expectNextMatches" failed (expected: onNext(); actual: onError(org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.example.reactivemongoprojectionissue.bmodels.ApiSubTransaction] to type [com.example.reactivemongoprojectionissue.models.SubTransactionProjection]))
	at reactor.test.MessageFormatter.assertionError(MessageFormatter.java:115)
	at reactor.test.MessageFormatter.failPrefix(MessageFormatter.java:104)
	at reactor.test.MessageFormatter.fail(MessageFormatter.java:73)
	at reactor.test.MessageFormatter.failOptional(MessageFormatter.java:88)
	at reactor.test.DefaultStepVerifierBuilder.lambda$expectNextMatches$11(DefaultStepVerifierBuilder.java:556)
	at reactor.test.DefaultStepVerifierBuilder$SignalEvent.test(DefaultStepVerifierBuilder.java:2288)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onSignal(DefaultStepVerifierBuilder.java:1528)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onExpectation(DefaultStepVerifierBuilder.java:1476)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onError(DefaultStepVerifierBuilder.java:1129)
	at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.deferredError(FluxUsingWhen.java:398)
	at reactor.core.publisher.FluxUsingWhen$RollbackInner.onComplete(FluxUsingWhen.java:475)
	at reactor.core.publisher.Operators.complete(Operators.java:137)
	at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:46)
	at reactor.core.publisher.Mono.subscribe(Mono.java:4455)
	at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.onError(FluxUsingWhen.java:364)
	at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onError(MonoFlatMapMany.java:255)
	at reactor.core.publisher.FluxMap$MapSubscriber.onError(FluxMap.java:134)
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:106)
	at reactor.core.publisher.Operators.error(Operators.java:198)
	at reactor.core.publisher.MonoError.subscribe(MonoError.java:53)
	at reactor.core.publisher.Mono.subscribe(Mono.java:4455)
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:103)
	at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onError(MonoFlatMapMany.java:255)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:383)
	at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onNext(FluxConcatMap.java:251)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:814)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:739)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:161)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 11, 2024
@christophstrobl christophstrobl self-assigned this Jan 15, 2024
@christophstrobl
Copy link
Member

@ELMORABITYounes thanks for reporting and the reproducer. We'll have a look.

@christophstrobl
Copy link
Member

So there's a code snippet AbstractReactiveMongoQuery:L139-L141 that resets the type to read. However that one had been there even before 3.4.3 so it's likely the cause is another one.
Might be a side effect of 52886e1. But requires further investigation.

@christophstrobl christophstrobl added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 15, 2024
@christophstrobl
Copy link
Member

confirmed - context resolution for the given property is breaking the interface projection for nested objects.

@mp911de mp911de linked a pull request Jan 19, 2024 that will close this issue
@mp911de mp911de changed the title Recursive Interface-based projection not working as expected in reactive repositories since 3.4.3 Nested Interface-based projection fails with ConverterNotFoundException Jan 19, 2024
@mp911de mp911de added this to the 4.1.9 (2023.0.9) milestone Jan 19, 2024
mp911de pushed a commit that referenced this issue Jan 22, 2024
mp911de pushed a commit that referenced this issue Jan 22, 2024
@mp911de mp911de reopened this Jan 22, 2024
@mp911de mp911de closed this as completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants