Skip to content

Commit eac490d

Browse files
committed
Upgrade to Reactor 2025.0.0-M5 and Micrometer 1.16.0-M1
Includes Netty 4.2.3 Closes gh-35169 Closes gh-35170
1 parent 20a1261 commit eac490d

File tree

4 files changed

+52
-30
lines changed

4 files changed

+52
-30
lines changed

framework-platform/framework-platform.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ javaPlatform {
88

99
dependencies {
1010
api(platform("com.fasterxml.jackson:jackson-bom:2.18.4"))
11-
api(platform("io.micrometer:micrometer-bom:1.15.1"))
12-
api(platform("io.netty:netty-bom:4.2.2.Final"))
13-
api(platform("io.projectreactor:reactor-bom:2025.0.0-M4"))
11+
api(platform("io.micrometer:micrometer-bom:1.16.0-M1"))
12+
api(platform("io.netty:netty-bom:4.2.3.Final"))
13+
api(platform("io.projectreactor:reactor-bom:2025.0.0-M5"))
1414
api(platform("io.rsocket:rsocket-bom:1.1.5"))
1515
api(platform("org.apache.groovy:groovy-bom:4.0.27"))
1616
api(platform("org.apache.logging.log4j:log4j-bom:3.0.0-beta3"))

spring-web/src/main/java/org/springframework/http/server/observation/DefaultServerRequestObservationConvention.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import io.micrometer.common.KeyValue;
2525
import io.micrometer.common.KeyValues;
26+
import org.jspecify.annotations.Nullable;
2627

2728
import org.springframework.http.HttpMethod;
2829
import org.springframework.http.HttpStatus;
@@ -89,12 +90,15 @@ public String getName() {
8990
}
9091

9192
@Override
92-
public String getContextualName(ServerRequestObservationContext context) {
93-
String httpMethod = context.getCarrier().getMethod().toLowerCase(Locale.ROOT);
94-
if (context.getPathPattern() != null) {
95-
return "http " + httpMethod + " " + context.getPathPattern();
93+
public @Nullable String getContextualName(ServerRequestObservationContext context) {
94+
if (context.getCarrier() != null) {
95+
String httpMethod = context.getCarrier().getMethod().toLowerCase(Locale.ROOT);
96+
if (context.getPathPattern() != null) {
97+
return "http " + httpMethod + " " + context.getPathPattern();
98+
}
99+
return "http " + httpMethod;
96100
}
97-
return "http " + httpMethod;
101+
return null;
98102
}
99103

100104
@Override

spring-web/src/main/java/org/springframework/http/server/reactive/observation/DefaultServerRequestObservationConvention.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import io.micrometer.common.KeyValue;
2323
import io.micrometer.common.KeyValues;
24+
import org.jspecify.annotations.Nullable;
2425

2526
import org.springframework.http.HttpMethod;
2627
import org.springframework.http.HttpStatus;
@@ -87,12 +88,15 @@ public String getName() {
8788
}
8889

8990
@Override
90-
public String getContextualName(ServerRequestObservationContext context) {
91-
String httpMethod = context.getCarrier().getMethod().name().toLowerCase(Locale.ROOT);
92-
if (context.getPathPattern() != null) {
93-
return "http " + httpMethod + " " + context.getPathPattern();
91+
public @Nullable String getContextualName(ServerRequestObservationContext context) {
92+
if (context.getCarrier() != null) {
93+
String httpMethod = context.getCarrier().getMethod().name().toLowerCase(Locale.ROOT);
94+
if (context.getPathPattern() != null) {
95+
return "http " + httpMethod + " " + context.getPathPattern();
96+
}
97+
return "http " + httpMethod;
9498
}
95-
return "http " + httpMethod;
99+
return null;
96100
}
97101

98102
@Override

spring-web/src/main/java/org/springframework/web/filter/ServerHttpObservationFilter.java

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,23 @@
5555
public class ServerHttpObservationFilter extends OncePerRequestFilter {
5656

5757
/**
58-
* Name of the request attribute holding the {@link ServerRequestObservationContext context} for the current observation.
58+
* Name of the request attribute holding the {@link ServerRequestObservationContext} for the current observation.
5959
*/
60-
public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE = ServerHttpObservationFilter.class.getName() + ".context";
60+
public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE =
61+
ServerHttpObservationFilter.class.getName() + ".context";
6162

62-
private static final ServerRequestObservationConvention DEFAULT_OBSERVATION_CONVENTION = new DefaultServerRequestObservationConvention();
63+
private static final String CURRENT_OBSERVATION_ATTRIBUTE =
64+
ServerHttpObservationFilter.class.getName() + ".observation";
6365

64-
private static final String CURRENT_OBSERVATION_ATTRIBUTE = ServerHttpObservationFilter.class.getName() + ".observation";
66+
private static final ServerRequestObservationConvention DEFAULT_OBSERVATION_CONVENTION =
67+
new DefaultServerRequestObservationConvention();
6568

6669

6770
private final ObservationRegistry observationRegistry;
6871

6972
private final ServerRequestObservationConvention observationConvention;
7073

74+
7175
/**
7276
* Create an {@code HttpRequestsObservationFilter} that records observations
7377
* against the given {@link ObservationRegistry}. The default
@@ -89,14 +93,6 @@ public ServerHttpObservationFilter(ObservationRegistry observationRegistry, Serv
8993
this.observationConvention = observationConvention;
9094
}
9195

92-
/**
93-
* Get the current {@link ServerRequestObservationContext observation context} from the given request, if available.
94-
* @param request the current request
95-
* @return the current observation context
96-
*/
97-
public static Optional<ServerRequestObservationContext> findObservationContext(HttpServletRequest request) {
98-
return Optional.ofNullable((ServerRequestObservationContext) request.getAttribute(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE));
99-
}
10096

10197
@Override
10298
protected boolean shouldNotFilterAsyncDispatch() {
@@ -150,8 +146,9 @@ private Observation createOrFetchObservation(HttpServletRequest request, HttpSer
150146
Observation observation = (Observation) request.getAttribute(CURRENT_OBSERVATION_ATTRIBUTE);
151147
if (observation == null) {
152148
ServerRequestObservationContext context = new ServerRequestObservationContext(request, response);
153-
observation = ServerHttpObservationDocumentation.HTTP_SERVLET_SERVER_REQUESTS.observation(this.observationConvention,
154-
DEFAULT_OBSERVATION_CONVENTION, () -> context, this.observationRegistry).start();
149+
observation = ServerHttpObservationDocumentation.HTTP_SERVLET_SERVER_REQUESTS.observation(
150+
this.observationConvention, DEFAULT_OBSERVATION_CONVENTION, () -> context, this.observationRegistry)
151+
.start();
155152
request.setAttribute(CURRENT_OBSERVATION_ATTRIBUTE, observation);
156153
if (!observation.isNoop()) {
157154
request.setAttribute(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE, observation.getContext());
@@ -160,14 +157,32 @@ private Observation createOrFetchObservation(HttpServletRequest request, HttpSer
160157
return observation;
161158
}
162159

163-
static @Nullable Throwable unwrapServletException(Throwable ex) {
164-
return (ex instanceof ServletException) ? ex.getCause() : ex;
160+
161+
/**
162+
* Get the current {@link ServerRequestObservationContext observation context} from the given request, if available.
163+
* @param request the current request
164+
* @return the current observation context
165+
*/
166+
public static Optional<ServerRequestObservationContext> findObservationContext(HttpServletRequest request) {
167+
return Optional.ofNullable(
168+
(ServerRequestObservationContext) request.getAttribute(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE));
165169
}
166170

167171
static @Nullable Throwable fetchException(ServletRequest request) {
168172
return (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
169173
}
170174

175+
static Throwable unwrapServletException(Throwable ex) {
176+
if (ex instanceof ServletException) {
177+
Throwable cause = ex.getCause();
178+
if (cause != null) {
179+
return cause;
180+
}
181+
}
182+
return ex;
183+
}
184+
185+
171186
private static class ObservationAsyncListener implements AsyncListener {
172187

173188
private final Observation currentObservation;
@@ -195,7 +210,6 @@ public void onComplete(AsyncEvent event) {
195210
public void onError(AsyncEvent event) {
196211
this.currentObservation.error(unwrapServletException(event.getThrowable()));
197212
}
198-
199213
}
200214

201215
}

0 commit comments

Comments
 (0)