Giter VIP home page Giter VIP logo

Comments (2)

odrotbohm avatar odrotbohm commented on June 8, 2024

We rely on ArchUnit to detect the dependencies between the different modules, so I would have to resort to @codecholeric to comment on why that dependency is not detected.

Independent of that, we could check, that API types do not expose internal types in the signatures of public methods. That said, I think we can only make this opt-in, as it might still be a valid declaration as internal types might refer to those methods and might have to be able to invoke them. I can't imagine a case in which this couldn't be fixed by rearranging the types, but I guess it indeed could happen.

from spring-modulith.

codecholeric avatar codecholeric commented on June 8, 2024

Sorry, I somehow missed the notification on this 🙈 I assume that the exists(..) method you call comes from an interface and not just the implementation? Or is this a method that is purely existing on the implementation? Because in the latter case I would still guess a violation would be found and would be puzzled if not 🤔
To answer this more thoroughly I would need a little code sample that shows how exactly your stuff is implemented. Then I could also tell you why in this case it's not detected.
Judging just the little snippet I see I could imagine the following: OrderRepository implements OrderApi, OrderApi declares exists(id) as you call it and var repository is just translated by the compiler to the most generic interface that still satisfies the requirements, i.e. the type in the bytecode then is OrderApi 🤷‍♂️ In other words, I wouldn't be surprised if you could switch the return type of getInternalRepository() to OrderApi and everything else would just compile fine? In this case, while this is not exactly clean, it will also only let the most easy to fix violations slip through, i.e. they can't really contribute to a hard to fix entangled mess...
To check if my assumption here is valid you could adjust your code to OrderRepository repository = orderApi.getInternalRepository() and see if this causes a violation (given that exists(..) is really directly implemented on OrderRepository and doesn't come from an allowed supertype of some sort). Or you could create a specific method OrderRepository.testMe() (not present on any interface) and call that from there and see if this changes things.
In any case, if you would really want to prevent something like this you would have to enforce that internal types may not be exposed by any public modifier. Because, you could also declare something like OrderApi api = orderApi.getInternalRepository() and even though the return type would be an internal type, it's not used in that nature on the callsite. And by that the only violation that could ever be found for such a code is that the public method exposes the internal type. But that's a different thing as "depends" for ArchUnit, because if I declare OrderApi api = ... the code technically doesn't "depend" on the internal type, even though it's exposed.

from spring-modulith.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.