spring-projects / spring-projects/spring-data-rest

Unpredicatable exposed repository if referring an entity already associated to another repository [DATAREST-80]

Open
#465 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Marco Fago opened DATAREST-80 and commented

Try to define 2 different JPA repositories referring the same entity.
Nothing seems go go wrong, but just one will be exposed (apparentely in an unpredicatable way). Occasionally an IllegalArgumentException ("object is not an instance of declaring class") is thrown when referring to repository's methods.

I think it might be due to the way repositories are stored in org.springframework.data.repository.support.Repositories.Repositories, building a map with key the entity (so just one repository for entity can be stored)


Affects: 1.1.0.M1

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

Start by reproducing the case with two JPA repositories referring to the same entity, then inspect org.springframework.data.repository.support.Repositories.Repositories, especially its entity-keyed map. Check how repository methods are exposed and whether the IllegalArgumentException occurs. Done means repository exposure is deterministic and calls do not target the wrong declaring class.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.