Skip to content

Commit 15a6373

Browse files
committed
Avoid nullability warnings
1 parent 2a26870 commit 15a6373

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

spring-test/src/main/java/org/springframework/test/web/reactive/server/CookieAssertions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.test.web.reactive.server;
1818

1919
import java.time.Duration;
20+
import java.util.Objects;
2021
import java.util.function.Consumer;
2122

2223
import org.hamcrest.Matcher;
@@ -210,10 +211,10 @@ public WebTestClient.ResponseSpec sameSite(String name, String expected) {
210211
private ResponseCookie getCookie(String name) {
211212
ResponseCookie cookie = this.exchangeResult.getResponseCookies().getFirst(name);
212213
if (cookie == null) {
213-
String message = "No cookie with name '" + name + "'";
214-
this.exchangeResult.assertWithDiagnostics(() -> AssertionErrors.fail(message));
214+
this.exchangeResult.assertWithDiagnostics(() ->
215+
AssertionErrors.fail("No cookie with name '" + name + "'"));
215216
}
216-
return cookie;
217+
return Objects.requireNonNull(cookie);
217218
}
218219

219220
private String getMessage(String cookie) {

spring-test/src/main/java/org/springframework/test/web/reactive/server/HeaderAssertions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import java.net.URI;
2020
import java.util.Arrays;
2121
import java.util.List;
22+
import java.util.Objects;
2223
import java.util.function.Consumer;
2324

2425
import org.hamcrest.Matcher;
@@ -73,7 +74,7 @@ public WebTestClient.ResponseSpec valueEquals(String headerName, long value) {
7374
String actual = getHeaders().getFirst(headerName);
7475
this.exchangeResult.assertWithDiagnostics(() ->
7576
assertTrue("Response does not contain header '" + headerName + "'", actual != null));
76-
return assertHeader(headerName, value, Long.parseLong(actual));
77+
return assertHeader(headerName, value, Long.parseLong(Objects.requireNonNull(actual)));
7778
}
7879

7980
/**
@@ -203,7 +204,7 @@ private List<String> getRequiredValues(String name) {
203204
this.exchangeResult.assertWithDiagnostics(() ->
204205
AssertionErrors.fail(getMessage(name) + " not found"));
205206
}
206-
return values;
207+
return Objects.requireNonNull(values);
207208
}
208209

209210
/**

0 commit comments

Comments
 (0)