spring-projects / spring-projects/spring-data-commons

Why RepositoryMethodInvoker.doInvokeReactiveToSuspended strips coroutine continuation?

Open
#2,532 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: feedback-provided status: waiting-for-triage
Dominant language
Java
Stars
838
Forks
730
PR merge metrics
No merged PRs in 30d

Description

[Version: spring-data-commons-2.4.13]

Hi, I have quesiton during digging the behavior of r2dbc, CoroutineCrudRepository.

First of all, What I want to do is logging query with some metadata that only can be retrieved from outer reactor or coroutine context (ex> ipath, eventId, spanId ..).

What I try first is

  1. Register ProxyConnectionFactory and register listener to log query.
  2. I wrote the code inside proxy listener that obtain "currentCoroutineContext[ReactorContext]" and use them when logging

But I found that "currentCoroutineContext[ReactorContext]" returns empty.

And I digging the repository behavior and I encounter below code.
image
Does the code in L168 means that all methods that are invoked in repository interface loose outer ractor or coroutine context?

Is there any way that can pass the outer coroutine or reactor context into repository method invokation?

Thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The entry point is RepositoryMethodInvoker.doInvokeReactiveToSuspended, with the report pointing to line 168; review it alongside CoroutineCrudRepository and the ProxyConnectionFactory listener scenario. Reproduce the missing currentCoroutineContext[ReactorContext] behavior and establish whether repository invocation preserves the outer context; done means a confirmed explanation or a narrowly defined change with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin, spring
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.