Commit a17c308
committed
Fix RestClient unnecessary bean creation in Spring Boot autoconfiguration
The RestClientBeanPostProcessor was creating a new RestClient bean every time
it processed a bean, even when the OpenTelemetry interceptor was already present.
This resulted in unnecessary bean creation and caused issues with proxy/delegate
RestClient beans.
Changes:
- Modified RestClientBeanPostProcessor to track whether the interceptor was
actually added during the mutation operation
- Return the original bean instance if the interceptor is already present
- Only create a new bean instance when the interceptor is actually added
- Added test case to verify bean identity is preserved when interceptor exists
This fix ensures that:
1. No unnecessary bean creation occurs when the interceptor is already present
2. Proxy/delegate RestClient beans work correctly
3. RestClient beans created with an injected RestClient.Builder that already
has the interceptor configured are not unnecessarily mutated
Fixes the issue where RestClient beans with the OTel interceptor already
configured would still trigger mutation and new bean creation.1 parent ad6cc1b commit a17c308
File tree
2 files changed
+44
-12
lines changed- instrumentation/spring/spring-boot-autoconfigure/src
- main/javaSpring3/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/web
- testSpring3/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/web
2 files changed
+44
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
90 | 115 | | |
0 commit comments