A dynamic proxy is a runtime-generated object that implements an interface and selects the method implementation during execution. Frameworks use it to keep an abstraction separate from its implementation. section 6.1
This decoupling makes framework capabilities convenient to call but difficult to investigate by reading application code. The visible interface may conceal the dependency method that performs the real work. section 6.1
When investigating code that uses dynamic proxies:
- Start with the observable symptom, such as an endpoint that takes about five seconds to respond. section 6.1
- Sample the running process, expand active-thread stacks, and inspect methods from both the application and its dependencies. section 6.1
- Use execution time and waiting behavior to locate the hidden implementation responsible for the delay. section 6.1
Feign interface hiding an HTTP implementation
An OpenFeign interface declares a POST request to /delay/{n}. Application code calls the interface, while the framework supplies the actual HTTP implementation at runtime. A profiler can reveal the dependency methods involved in the request. section 6.1
Figure 6.7 The framework keeps the implementations for an abstraction separate and provides them dynamically during execution. Because the implementation is decoupled and the app provides it during run time, it’s more difficult to find it by reading the code.
Shows how a framework keeps implementations separate from an abstraction and provides them during execution. section 6.1
