Browse Source

Add nullability annotations to smoke-test/spring-boot-smoke-test-websocket-jetty

See gh-46587
pull/46818/head
Moritz Halbritter 4 months ago
parent
commit
5c44a56ff4
  1. 20
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/client/package-info.java
  2. 4
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/echo/DefaultEchoService.java
  3. 20
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/echo/package-info.java
  4. 20
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/package-info.java
  5. 20
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/reverse/package-info.java
  6. 4
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/Location.java
  7. 3
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeTimer.java
  8. 7
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/SnakeWebSocketHandler.java
  9. 20
      smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/package-info.java

20
smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/client/package-info.java

@ -0,0 +1,20 @@ @@ -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.jetty.client;
import org.jspecify.annotations.NullMarked;

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

@ -16,11 +16,13 @@ @@ -16,11 +16,13 @@
package smoketest.websocket.jetty.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";
}

20
smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/echo/package-info.java

@ -0,0 +1,20 @@ @@ -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.jetty.echo;
import org.jspecify.annotations.NullMarked;

20
smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/package-info.java

@ -0,0 +1,20 @@ @@ -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.jetty;
import org.jspecify.annotations.NullMarked;

20
smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/reverse/package-info.java

@ -0,0 +1,20 @@ @@ -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.jetty.reverse;
import org.jspecify.annotations.NullMarked;

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

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package smoketest.websocket.jetty.snake;
import org.jspecify.annotations.Nullable;
public class Location {
/**
@ -44,7 +46,7 @@ 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;
}

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

@ -24,6 +24,7 @@ import java.util.TimerTask; @@ -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 { @@ -40,7 +41,7 @@ public final class SnakeTimer {
private static final ConcurrentHashMap<Integer, Snake> snakes = new ConcurrentHashMap<>();
private static Timer gameTimer = null;
private static @Nullable Timer gameTimer;
private SnakeTimer() {
}

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

@ -21,6 +21,9 @@ import java.util.Iterator; @@ -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 { @@ -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 { @@ -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 { @@ -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));
}

20
smoke-test/spring-boot-smoke-test-websocket-jetty/src/main/java/smoketest/websocket/jetty/snake/package-info.java

@ -0,0 +1,20 @@ @@ -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.jetty.snake;
import org.jspecify.annotations.NullMarked;
Loading…
Cancel
Save