Skip to content

Commit 7ef2fb0

Browse files
Removed nullUnmarked annotation from observability web classes
Fixes #17815 Signed-off-by: Soumik Sarker <ronodhirsoumik@gmail.com>
1 parent 8692185 commit 7ef2fb0

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

web/src/main/java/org/springframework/security/web/ObservationFilterChainDecorator.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import jakarta.servlet.http.HttpServletRequest;
3838
import org.apache.commons.logging.Log;
3939
import org.apache.commons.logging.LogFactory;
40-
import org.jspecify.annotations.NullUnmarked;
4140
import org.jspecify.annotations.Nullable;
4241

4342
import org.springframework.core.log.LogMessage;
@@ -51,7 +50,6 @@
5150
* @author Nikita Konev
5251
* @since 6.0
5352
*/
54-
@NullUnmarked // https://github.com/spring-projects/spring-security/issues/17815
5553
public final class ObservationFilterChainDecorator implements FilterChainProxy.FilterChainDecorator {
5654

5755
private static final Log logger = LogFactory.getLog(FilterChainProxy.class);
@@ -107,7 +105,8 @@ private List<ObservationFilter> wrap(List<Filter> filters) {
107105
}
108106

109107
static AroundFilterObservation observation(HttpServletRequest request) {
110-
return (AroundFilterObservation) request.getAttribute(ATTRIBUTE);
108+
AroundFilterObservation observation = (AroundFilterObservation) request.getAttribute(ATTRIBUTE);
109+
return (observation != null) ? observation : AroundFilterObservation.NOOP;
111110
}
112111

113112
private static final class VirtualFilterChain implements FilterChain {
@@ -377,11 +376,10 @@ private static final class ObservationReference {
377376

378377
private final Observation observation;
379378

380-
private volatile Observation.Scope scope;
379+
private volatile Observation.Scope scope = Observation.Scope.NOOP;
381380

382381
private ObservationReference(Observation observation) {
383382
this.observation = observation;
384-
this.scope = Observation.Scope.NOOP;
385383
}
386384

387385
private void start() {
@@ -510,7 +508,7 @@ static final class FilterChainObservationContext extends Observation.Context {
510508

511509
private final String filterSection;
512510

513-
private @Nullable String filterName;
511+
@Nullable private String filterName;
514512

515513
private int chainPosition;
516514

web/src/main/java/org/springframework/security/web/server/ObservationWebFilterChainDecorator.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,22 @@
2020
import java.util.List;
2121
import java.util.ListIterator;
2222

23-
import io.micrometer.common.KeyValue;
24-
import io.micrometer.common.KeyValues;
25-
import io.micrometer.observation.Observation;
26-
import io.micrometer.observation.ObservationConvention;
27-
import io.micrometer.observation.ObservationRegistry;
28-
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
29-
import org.jspecify.annotations.NullUnmarked;
3023
import org.jspecify.annotations.Nullable;
31-
import reactor.core.publisher.Mono;
32-
3324
import org.springframework.util.Assert;
3425
import org.springframework.util.StringUtils;
3526
import org.springframework.web.server.ServerWebExchange;
3627
import org.springframework.web.server.WebFilter;
3728
import org.springframework.web.server.WebFilterChain;
3829
import org.springframework.web.server.WebHandler;
3930

31+
import io.micrometer.common.KeyValue;
32+
import io.micrometer.common.KeyValues;
33+
import io.micrometer.observation.Observation;
34+
import io.micrometer.observation.ObservationConvention;
35+
import io.micrometer.observation.ObservationRegistry;
36+
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
37+
import reactor.core.publisher.Mono;
38+
4039
/**
4140
* A
4241
* {@link org.springframework.security.web.server.WebFilterChainProxy.WebFilterChainDecorator}
@@ -45,7 +44,6 @@
4544
* @author Josh Cummings
4645
* @since 6.0
4746
*/
48-
@NullUnmarked // https://github.com/spring-projects/spring-security/issues/17815
4947
public final class ObservationWebFilterChainDecorator implements WebFilterChainProxy.WebFilterChainDecorator {
5048

5149
private static final String ATTRIBUTE = ObservationWebFilterChainDecorator.class + ".observation";
@@ -70,8 +68,9 @@ public WebFilterChain decorate(WebFilterChain original, List<WebFilter> filters)
7068
return new ObservationWebFilterChain(wrapSecured(original)::filter, wrap(filters));
7169
}
7270

73-
private static @Nullable AroundWebFilterObservation observation(ServerWebExchange exchange) {
74-
return exchange.getAttribute(ATTRIBUTE);
71+
private static AroundWebFilterObservation observation(ServerWebExchange exchange) {
72+
AroundWebFilterObservation observation = exchange.getAttribute(ATTRIBUTE);
73+
return (observation != null) ? observation : AroundWebFilterObservation.NOOP;
7574
}
7675

7776
private WebFilterChain wrapSecured(WebFilterChain original) {
@@ -218,7 +217,7 @@ private Mono<Void> wrapFilter(ServerWebExchange exchange, WebFilterChain chain)
218217
});
219218
}
220219

221-
private AroundWebFilterObservation parent(ServerWebExchange exchange, Observation parentObservation) {
220+
private AroundWebFilterObservation parent(ServerWebExchange exchange, @Nullable Observation parentObservation) {
222221
WebFilterChainObservationContext beforeContext = WebFilterChainObservationContext.before();
223222
WebFilterChainObservationContext afterContext = WebFilterChainObservationContext.after();
224223
Observation before = Observation.createNotStarted(this.convention, () -> beforeContext, this.registry)
@@ -575,7 +574,7 @@ static final class WebFilterChainObservationContext extends Observation.Context
575574

576575
private final String filterSection;
577576

578-
private @Nullable String filterName;
577+
@Nullable private String filterName;
579578

580579
private int chainPosition;
581580

0 commit comments

Comments
 (0)