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

Recommended test for @Transactional does not work in combination with generic interface/super class #1193

Open
MariusKl opened this issue Nov 15, 2023 · 0 comments

Comments

@MariusKl
Copy link

I use your recommended test to avoid internal calls to methods with @Transactional

no_classes_should_directly_call_other_methods_declared_in_the_same_class_that_are_annotated_with(
            Transactional.class);

Unfortunately this does not work if the method is an implementation of a generic interface method

public interface ItemProcessor<I, O> {
    Integer process(I var1) throws Exception;
}

public class LoadProcessor implements ItemProcessor<String, Integer> {

    @Override
    @Transactional
    public Integer process(String var1) throws Exception {
        return null;
    }
}

The result is
java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'no classes should directly call other methods declared in the same class that are annotated with @Transactional, because it bypasses the proxy mechanism' was violated (1 times): Method <org.example.LoadProcessor.process(java.lang.Object)> calls method <org.example.LoadProcessor.process(java.lang.String)> in (LoadProcessor.java:5)

Same result if ItemProcessor is an abstract class. Tested with archunit-junit5 in version 1.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant