Method occurs multiple times and is registered twice

Description

When opening the pet-clinic owner overview (http://localhost:8080/#!/owners) inspectIT shows the findAll method of the SimpleJpaRepository multiple times (nested call) even it does not call itself in the code. When we have a look on the method calls of the corresponding invocation, the method occurs two times which means it has different method idents.

A storage containing the invocation sequences is attached.

Environment

None

Activity

Show:
Marius Oehler
October 2, 2017, 3:11 PM

Ok, we invested some time into this problem and find the cause why this "problem" occurs. Basically it is not a problem but as Java works.

In the case above, we have the following scenario: Spring uses a instance of class "SimpleJpaRepository" which implements the interface "CrudRepository". This interface provides the method "Iterable<T> findAll()" which is overridden by the concrete class with a more specified return value: "List<T> findAll()". In this case, the concrete class (here: SimpleJpaRepository) contains both methods, the one with the return value type "Iterable" and the one with "List". Because of this, inspectIT registers both methods as a unique method, which is actually correct!

When calling the findAll of "SimpleJpaRepository", the implemented method is called directly, but when the call was made against the interface class (e.g. ((CrudRepository) mySimpleJpaRepository).findAll() ), the call is done against the interface and after that on the actual implementation is invoked. See the attached screenshots where we implemented the same scenario in a dummy application. Here, we can see that there are two methods on the stack where we basically are calling one.

So, what we are seeing in inspectIT is correct.

Done

Assignee

Marius Oehler

Reporter

Marius Oehler