Add nullability annotations to smoke-test/spring-boot-smoke-test-websocket-undertow
See gh-46587
This commit is contained in:
parent
9dc74d5b23
commit
961f8e5e92
|
@ -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;
|
|
@ -16,11 +16,13 @@
|
||||||
|
|
||||||
package smoketest.websocket.undertow.echo;
|
package smoketest.websocket.undertow.echo;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
public class DefaultEchoService implements EchoService {
|
public class DefaultEchoService implements EchoService {
|
||||||
|
|
||||||
private final String echoFormat;
|
private final String echoFormat;
|
||||||
|
|
||||||
public DefaultEchoService(String echoFormat) {
|
public DefaultEchoService(@Nullable String echoFormat) {
|
||||||
this.echoFormat = (echoFormat != null) ? echoFormat : "%s";
|
this.echoFormat = (echoFormat != null) ? echoFormat : "%s";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
@ -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;
|
|
@ -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;
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package smoketest.websocket.undertow.snake;
|
package smoketest.websocket.undertow.snake;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
public class Location {
|
public class Location {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +46,7 @@ public class Location {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(@Nullable Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.TimerTask;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public final class SnakeTimer {
|
||||||
|
|
||||||
private static final ConcurrentHashMap<Integer, Snake> snakes = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<Integer, Snake> snakes = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static Timer gameTimer = null;
|
private static @Nullable Timer gameTimer;
|
||||||
|
|
||||||
private SnakeTimer() {
|
private SnakeTimer() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@ import java.util.Iterator;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
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.CloseStatus;
|
||||||
import org.springframework.web.socket.TextMessage;
|
import org.springframework.web.socket.TextMessage;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
import org.springframework.web.socket.WebSocketSession;
|
||||||
|
@ -34,7 +37,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
private Snake snake;
|
private @Nullable Snake snake;
|
||||||
|
|
||||||
public static String getRandomHexColor() {
|
public static String getRandomHexColor() {
|
||||||
float hue = random.nextFloat();
|
float hue = random.nextFloat();
|
||||||
|
@ -79,6 +82,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
||||||
|
Assert.state(this.snake != null, "'snake' must not be null");
|
||||||
String payload = message.getPayload();
|
String payload = message.getPayload();
|
||||||
switch (payload) {
|
switch (payload) {
|
||||||
case "west" -> this.snake.setDirection(Direction.WEST);
|
case "west" -> this.snake.setDirection(Direction.WEST);
|
||||||
|
@ -90,6 +94,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
||||||
|
Assert.state(this.snake != null, "'snake' must not be null");
|
||||||
SnakeTimer.removeSnake(this.snake);
|
SnakeTimer.removeSnake(this.snake);
|
||||||
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", this.id));
|
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", this.id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
Loading…
Reference in New Issue