diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/client/package-info.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/client/package-info.java new file mode 100644 index 00000000000..c85883b6f99 --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/client/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.websocket.undertow.client; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/DefaultEchoService.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/DefaultEchoService.java index 8da8930e2a7..c0878b6168b 100644 --- a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/DefaultEchoService.java +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/DefaultEchoService.java @@ -16,11 +16,13 @@ package smoketest.websocket.undertow.echo; +import org.jspecify.annotations.Nullable; + public class DefaultEchoService implements EchoService { private final String echoFormat; - public DefaultEchoService(String echoFormat) { + public DefaultEchoService(@Nullable String echoFormat) { this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/package-info.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/package-info.java new file mode 100644 index 00000000000..1406b42e9df --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/echo/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.websocket.undertow.echo; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/package-info.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/package-info.java new file mode 100644 index 00000000000..b8a8785b402 --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.websocket.undertow; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/reverse/package-info.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/reverse/package-info.java new file mode 100644 index 00000000000..c336f4e3026 --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/reverse/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.websocket.undertow.reverse; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Location.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Location.java index ab6c1d28805..c86aae589fb 100644 --- a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Location.java +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/Location.java @@ -16,6 +16,8 @@ package smoketest.websocket.undertow.snake; +import org.jspecify.annotations.Nullable; + public class Location { /** @@ -44,7 +46,7 @@ public class Location { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java index 8d01c7f6d99..dc712240989 100644 --- a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeTimer.java @@ -24,6 +24,7 @@ import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import jakarta.annotation.Nullable; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -40,7 +41,7 @@ public final class SnakeTimer { private static final ConcurrentHashMap snakes = new ConcurrentHashMap<>(); - private static Timer gameTimer = null; + private static @Nullable Timer gameTimer; private SnakeTimer() { } diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java index 8343a8bf4cb..f9175391905 100644 --- a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/SnakeWebSocketHandler.java @@ -21,6 +21,9 @@ import java.util.Iterator; import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; +import org.jspecify.annotations.Nullable; + +import org.springframework.util.Assert; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -34,7 +37,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler { private final int id; - private Snake snake; + private @Nullable Snake snake; public static String getRandomHexColor() { float hue = random.nextFloat(); @@ -79,6 +82,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { + Assert.state(this.snake != null, "'snake' must not be null"); String payload = message.getPayload(); switch (payload) { case "west" -> this.snake.setDirection(Direction.WEST); @@ -90,6 +94,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler { @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { + Assert.state(this.snake != null, "'snake' must not be null"); SnakeTimer.removeSnake(this.snake); SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", this.id)); } diff --git a/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/package-info.java b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/package-info.java new file mode 100644 index 00000000000..06e4eedbc4b --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-websocket-undertow/src/main/java/smoketest/websocket/undertow/snake/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.websocket.undertow.snake; + +import org.jspecify.annotations.NullMarked;