I have the following code:
@Service
public class ItemService {
...
public void addItems(@Nonnull DocumentDTO dto) throws Exception {
// some code that takes some time to process
...
addItems(dto.getDocId(), items);
}
@Transactional
public void addItems(long docId, @Nonnull List<Item> items) {
itemDao.addItems(docId, items);
}
}
The first method is not @Transactional and it calls the second one with @Transactional. SonarLint tool states that "Methods should not call same-class methods with incompatible "@Transactional" values" (https://rules.sonarsource.com/java/RSPEC-2229)
But this code works correctly in Spring 4.3.20. Is this rule actual for Spring 4.3.20?
P.S. Interesting, if I make the second method as package-private, the SonarLint warning disappears... Why?