Skip to content

Commit 961f8e5

Browse files
committed
Add nullability annotations to smoke-test/spring-boot-smoke-test-websocket-undertow
See gh-46587
1 parent 9dc74d5 commit 961f8e5

File tree

9 files changed

+114
-4
lines changed

9 files changed

+114
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package smoketest.websocket.undertow.client;
19+
20+
import org.jspecify.annotations.NullMarked;

smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/DefaultEchoService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
package smoketest.websocket.undertow.echo;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
public class DefaultEchoService implements EchoService {
2022

2123
private final String echoFormat;
2224

23-
public DefaultEchoService(String echoFormat) {
25+
public DefaultEchoService(@Nullable String echoFormat) {
2426
this.echoFormat = (echoFormat != null) ? echoFormat : "%s";
2527
}
2628

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package smoketest.websocket.undertow.echo;
19+
20+
import org.jspecify.annotations.NullMarked;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package smoketest.websocket.undertow;
19+
20+
import org.jspecify.annotations.NullMarked;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package smoketest.websocket.undertow.reverse;
19+
20+
import org.jspecify.annotations.NullMarked;

smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Location.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package smoketest.websocket.undertow.snake;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
public class Location {
2022

2123
/**
@@ -44,7 +46,7 @@ public Location getAdjacentLocation(Direction direction) {
4446
}
4547

4648
@Override
47-
public boolean equals(Object o) {
49+
public boolean equals(@Nullable Object o) {
4850
if (this == o) {
4951
return true;
5052
}

smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.concurrent.ConcurrentHashMap;
2525
import java.util.concurrent.CopyOnWriteArrayList;
2626

27+
import jakarta.annotation.Nullable;
2728
import org.apache.commons.logging.Log;
2829
import org.apache.commons.logging.LogFactory;
2930

@@ -40,7 +41,7 @@ public final class SnakeTimer {
4041

4142
private static final ConcurrentHashMap<Integer, Snake> snakes = new ConcurrentHashMap<>();
4243

43-
private static Timer gameTimer = null;
44+
private static @Nullable Timer gameTimer;
4445

4546
private SnakeTimer() {
4647
}

smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.util.Random;
2222
import java.util.concurrent.atomic.AtomicInteger;
2323

24+
import org.jspecify.annotations.Nullable;
25+
26+
import org.springframework.util.Assert;
2427
import org.springframework.web.socket.CloseStatus;
2528
import org.springframework.web.socket.TextMessage;
2629
import org.springframework.web.socket.WebSocketSession;
@@ -34,7 +37,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
3437

3538
private final int id;
3639

37-
private Snake snake;
40+
private @Nullable Snake snake;
3841

3942
public static String getRandomHexColor() {
4043
float hue = random.nextFloat();
@@ -79,6 +82,7 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio
7982

8083
@Override
8184
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
85+
Assert.state(this.snake != null, "'snake' must not be null");
8286
String payload = message.getPayload();
8387
switch (payload) {
8488
case "west" -> this.snake.setDirection(Direction.WEST);
@@ -90,6 +94,7 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
9094

9195
@Override
9296
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
97+
Assert.state(this.snake != null, "'snake' must not be null");
9398
SnakeTimer.removeSnake(this.snake);
9499
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", this.id));
95100
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package smoketest.websocket.undertow.snake;
19+
20+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)