Closes gh-28495

Motivation

@HttpExchange("http://localhost:8080")
public interface GreetingClient {

    @GetExchange("/greeting")
    Flux<Greeting> greetings();

    default Flux<Greeting> defaultMethod() {
        return greetings(new Greeting("default method test"))
                .flatMapMany(it -> greetings());
    }
}
  • Like https://github.com/spring-projects/spring-framework/issues/28491, we may need to support default method on more proxies

In JDK dynamic proxies created by Spring AOP, .. we cound make it(support default method) easier via a utility.

  • Based on https://github.com/spring-projects/spring-framework/issues/28495#issue-1243003876, I want to introduce ReflectiveMethodInvocationUtils#invokeDefaultMethod first to support default method easily via a utility and reduce duplicated code!

Modification

  • Add ReflectiveMethodInvocationUtils#invokeDefaultMethod
  • Replace duplicated default method invocation code on HttpServiceProxyFactory and RSocketServiceProxyFactory

Result

  • Now we can easily support default method via a utiliy in JDK dynamic proxies created by Spring AOP
  • Close gh-28495

Comment From: jhoeller

On review, I don't really see a need for extracting common logic there since it is a pretty straight invocation anyway, just a condition and a cast but then being able to return straight away.

From where we stand right now, #28495 is rather about where else to invoke default methods the same way. If we identify such further places, I don't mind copying the same condition logic there.

Comment From: injae-kim

rather about where else to invoke default methods the same way. If we identify such further places, I don't mind copying the same condition logic there.

Aha~ I understood. I think #28495 means extracting common logic 😅

Thanks you!