spring-projects / spring-projects/spring-modulith

internal types can be used inside methods - verify still succeeds

Open
#205 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Jun 1, 2023.

in: core meta: investigating type: enhancement
Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

Given the modules "order" and "inventory". The module order contains a package "internal" with a OrderRepository and has an interface OrderApi. The inventory module contains a service "OrderService" with a method "hasOrder".

Also we have a ModularityTest that calls verify on ApplicationModules.

We observed that the call to verify fails when we are returning the OrderRepository in the method getOrder. So far so good. However if we are just utilizing the OrderRepository inside the method but in the end return a boolean, the test does not fail.

For example:

@Autowired
private OrderApi orderApi;

public boolean hasOrder(UUID id) {
    var repository = orderApi.getInternalRepository();
    return repository.exists(id);
}

Thus according to our observation the verify test does not fully enforce that internal types cannot be used at all in another module. It only enforces that internal types cannot be used as return value (or parameters) in methods in another module.

I am aware that such a case might be a bit "searched for" (probably nobody would implement a getInternalRepository method ;D) but still think that the library might benefit from an improved validation (check that classes from other modules are not allowed at all to reference any internal class).

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.