diff --git a/header.txt b/header.txt index 172d1ba7..6c4e3ec6 100644 --- a/header.txt +++ b/header.txt @@ -1,4 +1,5 @@ -Copyright (c) 2012-2025 Nikita Koksharov +Copyright (c) 2025 The Socketio4j Project +Parent project : Copyright (c) 2012-2025 Nikita Koksharov Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckCallback.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckCallback.java index 2ec71fd7..2cac2d3a 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckCallback.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckCallback.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckMode.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckMode.java index ba9bc4c8..e819cccb 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckMode.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckMode.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckRequest.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckRequest.java index b78f071d..256d917e 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckRequest.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AckRequest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenListener.java index 86b0342e..9a4246c7 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenResult.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenResult.java index e14608cc..e550e4b3 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenResult.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthTokenResult.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationListener.java index 8e6888ea..983be256 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationResult.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationResult.java index aeeb1581..251582c9 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationResult.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/AuthorizationResult.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BasicConfiguration.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BasicConfiguration.java index aba41525..5fa26090 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BasicConfiguration.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BasicConfiguration.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,10 +16,12 @@ */ package com.corundumstudio.socketio; - import java.util.Arrays; import java.util.List; +import com.corundumstudio.socketio.nativeio.TransportType; + + /** * Basic configuration class, contains only primitive, String and enum types * as fields. Used as a base class for Configuration @@ -31,10 +34,9 @@ public abstract class BasicConfiguration { protected int bossThreads = 0; // 0 = current_processors_amount * 2 protected int workerThreads = 0; // 0 = current_processors_amount * 2 - protected boolean useLinuxNativeEpoll; - protected boolean useLinuxNativeIoUring; - protected boolean useUnixNativeKqueue; + protected TransportType transportType = TransportType.AUTO; + protected boolean allowCustomRequests = false; protected int upgradeTimeout = 10000; @@ -75,9 +77,7 @@ protected BasicConfiguration() { protected BasicConfiguration(BasicConfiguration conf) { setBossThreads(conf.getBossThreads()); setWorkerThreads(conf.getWorkerThreads()); - setUseLinuxNativeEpoll(conf.isUseLinuxNativeEpoll()); - setUseLinuxNativeIoUring(conf.isUseLinuxNativeIoUring()); - setUseUnixNativeKqueue(conf.isUseUnixNativeKqueue()); + setTransportType(conf.getTransportType()); setPingInterval(conf.getPingInterval()); setPingTimeout(conf.getPingTimeout()); setFirstDataTimeout(conf.getFirstDataTimeout()); @@ -353,29 +353,14 @@ public boolean isEnableCors() { return enableCors; } - public boolean isUseLinuxNativeEpoll() { - return useLinuxNativeEpoll; + public TransportType getTransportType() { + return transportType; } - public void setUseLinuxNativeEpoll(boolean useLinuxNativeEpoll) { - this.useLinuxNativeEpoll = useLinuxNativeEpoll; + public void setTransportType(TransportType transportType) { + this.transportType = transportType; } - public boolean isUseLinuxNativeIoUring() { - return useLinuxNativeIoUring; - } - - public void setUseLinuxNativeIoUring(boolean useLinuxNativeIoUring) { - this.useLinuxNativeIoUring = useLinuxNativeIoUring; - } - - public boolean isUseUnixNativeKqueue() { - return useUnixNativeKqueue; - } - - public void setUseUnixNativeKqueue(boolean useUnixNativeKqueue) { - this.useUnixNativeKqueue = useUnixNativeKqueue; - } /** * Set the response Access-Control-Allow-Headers * @@ -461,50 +446,4 @@ public boolean isNeedClientAuth() { return needClientAuth; } - /** - * Validates the native transport configuration. - *

- * Only one native transport may be enabled at a time. The supported native - * transports are: - *

- *

- * This method performs a bitmask-based check to ensure that at most one of the - * transport flags is enabled. If more than one flag is set, an - * {@link IllegalArgumentException} is thrown detailing which transports were - * simultaneously enabled. - * - * @throws IllegalArgumentException - * if more than one native transport is configured at the same time - */ - public void validate() { - int bits = 0; - if (isUseLinuxNativeIoUring()) bits |= 1; - if (isUseLinuxNativeEpoll()) bits |= 2; - if (isUseUnixNativeKqueue()) bits |= 4; - - if (Integer.bitCount(bits) > 1) { - throw new IllegalArgumentException( - "Only one native transport MUST be enabled: " + enabledTransports(bits) - ); - } - } - - - private String enabledTransports(int bits) { - StringBuilder sb = new StringBuilder(); - - sb.append("["); - if ((bits & 1) != 0) sb.append("io_uring "); - if ((bits & 2) != 0) sb.append("epoll "); - if ((bits & 4) != 0) sb.append("kqueue "); - sb.append("]"); - - return sb.toString().trim(); - } - - } diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastAckCallback.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastAckCallback.java index c629b5d5..14a9b7fa 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastAckCallback.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastAckCallback.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastOperations.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastOperations.java index 599a94f6..ff39f469 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastOperations.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/BroadcastOperations.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ClientOperations.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ClientOperations.java index de612a3b..42ec13da 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ClientOperations.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ClientOperations.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Configuration.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Configuration.java index 49164cf2..7fee5989 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Configuration.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Configuration.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Disconnectable.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Disconnectable.java index dcd34f4a..7f9ce0cb 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Disconnectable.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Disconnectable.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/DisconnectableHub.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/DisconnectableHub.java index 4f426648..a576b455 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/DisconnectableHub.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/DisconnectableHub.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HandshakeData.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HandshakeData.java index c32d84d7..615e5823 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HandshakeData.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HandshakeData.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HttpRequestDecoderConfiguration.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HttpRequestDecoderConfiguration.java index 20d25c0d..0210098e 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HttpRequestDecoderConfiguration.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/HttpRequestDecoderConfiguration.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/JsonSupportWrapper.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/JsonSupportWrapper.java index 640b6c17..32e16372 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/JsonSupportWrapper.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/JsonSupportWrapper.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiRoomBroadcastOperations.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiRoomBroadcastOperations.java index 2aa1e2d0..c55ff96c 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiRoomBroadcastOperations.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiRoomBroadcastOperations.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeAckCallback.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeAckCallback.java index 0f556057..3d5c005c 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeAckCallback.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeAckCallback.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeArgs.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeArgs.java index 8f134f21..f4430030 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeArgs.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/MultiTypeArgs.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ServerStatus.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ServerStatus.java index 90389372..6ab7a28d 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ServerStatus.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ServerStatus.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SingleRoomBroadcastOperations.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SingleRoomBroadcastOperations.java index f7349308..d75f795b 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SingleRoomBroadcastOperations.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SingleRoomBroadcastOperations.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketConfig.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketConfig.java index 686767ae..e0b9e873 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketConfig.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketConfig.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java index e4dcf195..c142e1eb 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOClient.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOClient.java index 3b842a43..0beffa5f 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOClient.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOClient.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIONamespace.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIONamespace.java index a28cfcfd..523661c4 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIONamespace.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIONamespace.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOServer.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOServer.java index 16927582..233579af 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOServer.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketIOServer.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,16 +23,6 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; -import io.netty.channel.*; -import io.netty.channel.epoll.Epoll; -import io.netty.channel.epoll.EpollIoHandler; -import io.netty.channel.kqueue.KQueue; -import io.netty.channel.kqueue.KQueueIoHandler; -import io.netty.channel.kqueue.KQueueServerSocketChannel; -import io.netty.channel.nio.NioIoHandler; -import io.netty.channel.uring.IoUring; -import io.netty.channel.uring.IoUringIoHandler; -import io.netty.channel.uring.IoUringServerSocketChannel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,21 +38,29 @@ import com.corundumstudio.socketio.namespace.NamespacesHub; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.epoll.EpollServerSocketChannel; +import io.netty.channel.ChannelOption; +import io.netty.channel.DefaultEventLoop; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.FixedRecvByteBufAllocator; +import io.netty.channel.IoHandlerFactory; +import io.netty.channel.MultiThreadIoEventLoopGroup; +import io.netty.channel.ServerChannel; +import io.netty.channel.WriteBufferWaterMark; +import io.netty.channel.nio.NioIoHandler; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; import io.netty.util.concurrent.SucceededFuture; + /** * Fully thread-safe. - * */ public class SocketIOServer implements ClientListeners { private static final Logger log = LoggerFactory.getLogger(SocketIOServer.class); - private final AtomicReference serverStatus = new AtomicReference(ServerStatus.INIT); + private final AtomicReference serverStatus = new AtomicReference<>(ServerStatus.INIT); private final Configuration configCopy; private final Configuration configuration; @@ -85,30 +84,14 @@ public void setPipelineFactory(SocketIOChannelInitializer pipelineFactory) { this.pipelineFactory = pipelineFactory; } - /** - * Get all clients connected to default namespace - * - * @return clients collection - */ public Collection getAllClients() { return namespacesHub.get(Namespace.DEFAULT_NAME).getAllClients(); } - /** - * Get client by uuid from default namespace - * - * @param uuid - id of client - * @return client - */ public SocketIOClient getClient(UUID uuid) { return namespacesHub.get(Namespace.DEFAULT_NAME).getClient(uuid); } - /** - * Get all namespaces - * - * @return namespaces collection - */ public Collection getAllNamespaces() { return namespacesHub.getAllNamespaces(); } @@ -116,123 +99,159 @@ public Collection getAllNamespaces() { public BroadcastOperations getBroadcastOperations() { Collection namespaces = namespacesHub.getAllNamespaces(); List list = new ArrayList<>(); - BroadcastOperations broadcast = null; - if (namespaces != null && !namespaces.isEmpty()) { + if (namespaces != null) { for (SocketIONamespace n : namespaces) { - broadcast = n.getBroadcastOperations(); - list.add(broadcast); + list.add(n.getBroadcastOperations()); } } return new MultiRoomBroadcastOperations(list); } - /** - * Get broadcast operations for clients within - * rooms by rooms' names - * - * @param rooms rooms' names - * @return broadcast operations - */ public BroadcastOperations getRoomOperations(String... rooms) { Collection namespaces = namespacesHub.getAllNamespaces(); - List list = new ArrayList(); - BroadcastOperations broadcast = null; - if (namespaces != null && !namespaces.isEmpty()) { + List list = new ArrayList<>(); + if (namespaces != null) { for (SocketIONamespace n : namespaces) { for (String room : rooms) { - broadcast = n.getRoomOperations(room); - list.add(broadcast); + list.add(n.getRoomOperations(room)); } } } return new MultiRoomBroadcastOperations(list); } - /** - * Start server - */ public void start() { startAsync().syncUninterruptibly(); } - /** - * Returns true if server is started - */ public boolean isStarted() { return serverStatus.get() == ServerStatus.STARTED; } - /** - * Start server asynchronously - * - * @return void - */ public Future startAsync() { if (!serverStatus.compareAndSet(ServerStatus.INIT, ServerStatus.STARTING)) { - log.warn("Invalid server state: {}, should be: {}, ignoring start request", serverStatus.get(), ServerStatus.INIT); - return new SucceededFuture(new DefaultEventLoop(), null); + log.warn("Invalid server state: {}, should be: {}, ignoring start request", + serverStatus.get(), ServerStatus.INIT); + return new SucceededFuture<>(new DefaultEventLoop(), null); } try { - log.info("Session store / pubsub factory used: {}", configCopy.getStoreFactory()); + log.info("Session store / pubsub factory: {}", configCopy.getStoreFactory()); initGroups(); - pipelineFactory.start(configCopy, namespacesHub); - configCopy.validate(); + Class channelClass; - Class channelClass = NioServerSocketChannel.class; + switch (configCopy.getTransportType()) { - if (configCopy.isUseLinuxNativeIoUring() && IoUring.isAvailable()) { - channelClass = IoUringServerSocketChannel.class; - } else if (configCopy.isUseLinuxNativeEpoll() && Epoll.isAvailable()) { - channelClass = EpollServerSocketChannel.class; - } else if (configCopy.isUseUnixNativeKqueue() && KQueue.isAvailable()) { - channelClass = KQueueServerSocketChannel.class; - } else { - log.warn("No selected native transport is available. Falling back to NIO"); - } + case IO_URING: + if (ioUringAvailable()) { + channelClass = loadChannelClass("io.netty.channel.uring.IoUringServerSocketChannel"); + } else { + channelClass = fallback("IO_URING unavailable"); + } + break; + case EPOLL: + if (epollAvailable()) { + channelClass = loadChannelClass("io.netty.channel.epoll.EpollServerSocketChannel"); + } else { + channelClass = fallback("EPOLL unavailable"); + } + break; - ServerBootstrap b = new ServerBootstrap(); - b.group(bossGroup, workerGroup) + case KQUEUE: + if (kqueueAvailable()) { + channelClass = loadChannelClass("io.netty.channel.kqueue.KQueueServerSocketChannel"); + } else { + channelClass = fallback("KQUEUE unavailable"); + } + break; + + case NIO: + channelClass = NioServerSocketChannel.class; + break; + + case AUTO: + default: + if (ioUringAvailable()) { + channelClass = loadChannelClass("io.netty.channel.uring.IoUringServerSocketChannel"); + log.info("AUTO selected IO_URING transport"); + } else if (epollAvailable()) { + channelClass = loadChannelClass("io.netty.channel.epoll.EpollServerSocketChannel"); + log.info("AUTO selected EPOLL transport"); + } else if (kqueueAvailable()) { + channelClass = loadChannelClass("io.netty.channel.kqueue.KQueueServerSocketChannel"); + log.info("AUTO selected KQUEUE transport"); + } else { + channelClass = NioServerSocketChannel.class; + log.info("AUTO selected NIO transport"); + } + } + + ServerBootstrap bootstrap = new ServerBootstrap(); + bootstrap.group(bossGroup, workerGroup) .channel(channelClass) .childHandler(pipelineFactory); - applyConnectionOptions(b); - InetSocketAddress addr = new InetSocketAddress(configCopy.getPort()); - if (configCopy.getHostname() != null) { - addr = new InetSocketAddress(configCopy.getHostname(), configCopy.getPort()); + applyConnectionOptions(bootstrap); + + InetSocketAddress address; + if (configCopy.getHostname() == null) { + address = new InetSocketAddress(configCopy.getPort()); + } else { + address = new InetSocketAddress(configCopy.getHostname(), configCopy.getPort()); } - return b.bind(addr).addListener(new FutureListener() { - @Override - public void operationComplete(Future future) throws Exception { - if (future.isSuccess()) { - serverStatus.set(ServerStatus.STARTED); - log.info("SocketIO server started at port: {}", configCopy.getPort()); - } else { - serverStatus.set(ServerStatus.INIT); - log.error("SocketIO server start failed at port: {}!", configCopy.getPort()); - } + return bootstrap.bind(address).addListener((FutureListener) future -> { + if (future.isSuccess()) { + serverStatus.set(ServerStatus.STARTED); + log.info("SocketIO server started on port {}", configCopy.getPort()); + } else { + serverStatus.set(ServerStatus.INIT); + log.error("Failed to start server on port {}", configCopy.getPort()); } }); + } catch (Exception e) { serverStatus.set(ServerStatus.INIT); - log.error("SocketIO server start error at port: {}! {}", configCopy.getPort(), e.getMessage(), e); + log.error("Server start error on port {}: {}", configCopy.getPort(), e.getMessage(), e); throw e; } } + private Class loadChannelClass(String name) { + try { + @SuppressWarnings("unchecked") + Class c = (Class) Class.forName(name); + return c; + } catch (Exception ignored) { + log.warn("Unable to load native channel {}. Using NIO.", name); + return NioServerSocketChannel.class; + } + } + + private Class fallback(String msg) { + log.warn("{} → Falling back to NIO.", msg); + return NioServerSocketChannel.class; + } + + private IoHandlerFactory fallbackFactory(String msg) { + log.warn("{} → Falling back to NIO IoHandler.", msg); + return NioIoHandler.newFactory(); + } + protected void applyConnectionOptions(ServerBootstrap bootstrap) { SocketConfig config = configCopy.getSocketConfig(); + bootstrap.childOption(ChannelOption.TCP_NODELAY, config.isTcpNoDelay()); + if (config.getTcpSendBufferSize() != -1) { bootstrap.childOption(ChannelOption.SO_SNDBUF, config.getTcpSendBufferSize()); } if (config.getTcpReceiveBufferSize() != -1) { bootstrap.childOption(ChannelOption.SO_RCVBUF, config.getTcpReceiveBufferSize()); - bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(config.getTcpReceiveBufferSize())); + bootstrap.childOption(ChannelOption.RECVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(config.getTcpReceiveBufferSize())); } //default value @see WriteBufferWaterMark.DEFAULT if (config.getWriteBufferWaterMarkLow() != -1 && config.getWriteBufferWaterMarkHigh() != -1) { @@ -250,33 +269,62 @@ protected void applyConnectionOptions(ServerBootstrap bootstrap) { protected void initGroups() { - configCopy.validate(); + IoHandlerFactory handler; + + switch (configCopy.getTransportType()) { + + case IO_URING: + handler = createHandler("io.netty.channel.uring.IoUringIoHandler", ioUringAvailable()); + break; + + case EPOLL: + handler = createHandler("io.netty.channel.epoll.EpollIoHandler", epollAvailable()); + break; - IoHandlerFactory ioHandler = NioIoHandler.newFactory(); // default + case KQUEUE: + handler = createHandler("io.netty.channel.kqueue.KQueueIoHandler", kqueueAvailable()); + break; - if (configCopy.isUseLinuxNativeIoUring() && IoUring.isAvailable()) { - ioHandler = IoUringIoHandler.newFactory(); - } else if (configCopy.isUseLinuxNativeEpoll() && Epoll.isAvailable()) { - ioHandler = EpollIoHandler.newFactory(); - } else if (configCopy.isUseUnixNativeKqueue() && KQueue.isAvailable()) { - ioHandler = KQueueIoHandler.newFactory(); + case NIO: + handler = NioIoHandler.newFactory(); + break; + + case AUTO: + default: + if (ioUringAvailable()) { + handler = createHandler("io.netty.channel.uring.IoUringIoHandler", true); + } else if (epollAvailable()) { + handler = createHandler("io.netty.channel.epoll.EpollIoHandler", true); + } else if (kqueueAvailable()) { + handler = createHandler("io.netty.channel.kqueue.KQueueIoHandler", true); + } else { + handler = fallbackFactory("No native transport available."); + } } - bossGroup = new MultiThreadIoEventLoopGroup(configCopy.getBossThreads(), ioHandler); - workerGroup = new MultiThreadIoEventLoopGroup(configCopy.getWorkerThreads(), ioHandler); + bossGroup = new MultiThreadIoEventLoopGroup(configCopy.getBossThreads(), handler); + workerGroup = new MultiThreadIoEventLoopGroup(configCopy.getWorkerThreads(), handler); + } + private IoHandlerFactory createHandler(String className, boolean available) { + if (!available) { + return fallbackFactory(className + " unavailable"); + } + try { + return (IoHandlerFactory) Class.forName(className) + .getMethod("newFactory") + .invoke(null); + } catch (Exception ignored) { + return fallbackFactory("Failed to load " + className); + } } - /** - * Stop server - */ public void stop() { if (!serverStatus.compareAndSet(ServerStatus.STARTED, ServerStatus.STOPPING)) { - log.warn("Invalid server state: {}, should be: {}, ignoring stop request", serverStatus.get(), ServerStatus.STARTED); + log.warn("Invalid server state {}, ignoring stop()", serverStatus.get()); return; } try { - log.info("Stopping SocketIO server..."); bossGroup.shutdownGracefully().syncUninterruptibly(); workerGroup.shutdownGracefully().syncUninterruptibly(); pipelineFactory.stop(); @@ -298,13 +346,6 @@ public void removeNamespace(String name) { namespacesHub.remove(name); } - /** - * Allows to get configuration provided - * during server creation. Further changes on - * this object not affect server. - * - * @return Configuration object - */ public Configuration getConfiguration() { return configuration; } @@ -325,7 +366,6 @@ public void addEventInterceptor(EventInterceptor eventInterceptor) { } - @Override public void removeAllListeners(String eventName) { mainNamespace.removeAllListeners(eventName); @@ -362,9 +402,45 @@ public void addListeners(Iterable listeners) { } @Override - public void addListeners(Object listeners, Class listenersClass) { - mainNamespace.addListeners(listeners, listenersClass); + public void addListeners(Object listeners, Class clazz) { + mainNamespace.addListeners(listeners, clazz); } + /* --------------------------------------------------------------------- + * Native Transport Detection — Safe Reflection + * --------------------------------------------------------------------- */ + + private static boolean isClassPresent(String name) { + try { + Class.forName(name, false, SocketIOServer.class.getClassLoader()); + return true; + } catch (Exception ignored) { + return false; + } + } + + private static boolean isNativeAvailable(String className, String method) { + try { + Class cls = Class.forName(className, false, SocketIOServer.class.getClassLoader()); + return (Boolean) cls.getMethod(method).invoke(null); + } catch (Exception ignored) { + return false; + } + } + + private static boolean ioUringAvailable() { + return isClassPresent("io.netty.channel.uring.IoUring") + && isNativeAvailable("io.netty.channel.uring.IoUring", "isAvailable"); + } + + private static boolean epollAvailable() { + return isClassPresent("io.netty.channel.epoll.Epoll") + && isNativeAvailable("io.netty.channel.epoll.Epoll", "isAvailable"); + } + + private static boolean kqueueAvailable() { + return isClassPresent("io.netty.channel.kqueue.KQueue") + && isNativeAvailable("io.netty.channel.kqueue.KQueue", "isAvailable"); + } } diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketSslConfig.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketSslConfig.java index f905176e..30e19ba2 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketSslConfig.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/SocketSslConfig.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Transport.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Transport.java index 7bb3ed99..6fe13948 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Transport.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/Transport.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/VoidAckCallback.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/VoidAckCallback.java index 6791b525..5a024da5 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/VoidAckCallback.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/VoidAckCallback.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckManager.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckManager.java index 26a52cb4..8dd4b54f 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckManager.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckManager.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +20,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -37,13 +39,11 @@ import com.corundumstudio.socketio.scheduler.SchedulerKey; import com.corundumstudio.socketio.scheduler.SchedulerKey.Type; -import io.netty.util.internal.PlatformDependent; - public class AckManager implements Disconnectable { static class AckEntry { - final Map> ackCallbacks = PlatformDependent.newConcurrentHashMap(); + final Map> ackCallbacks = new ConcurrentHashMap<>(); final AtomicLong ackIndex = new AtomicLong(-1); public long addAckCallback(AckCallback callback) { @@ -72,7 +72,7 @@ public void initAckIndex(long index) { private static final Logger log = LoggerFactory.getLogger(AckManager.class); - private final ConcurrentMap ackEntries = PlatformDependent.newConcurrentHashMap(); + private final ConcurrentMap ackEntries = new ConcurrentHashMap<>(); private final CancelableScheduler scheduler; diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckSchedulerKey.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckSchedulerKey.java index b9992d08..3afc96fa 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckSchedulerKey.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/ack/AckSchedulerKey.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/AnnotationScanner.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/AnnotationScanner.java index 271cfef7..15dcfa12 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/AnnotationScanner.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/AnnotationScanner.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnect.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnect.java index 9f966c81..eb86b89c 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnect.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnect.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnectScanner.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnectScanner.java index 1f66c2bd..69e72a05 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnectScanner.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnConnectScanner.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnect.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnect.java index 7a1ce2cd..7af9ad85 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnect.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnect.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnectScanner.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnectScanner.java index c32840fe..5b83b9d4 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnectScanner.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnDisconnectScanner.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEvent.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEvent.java index 41d48225..cf04f615 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEvent.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEvent.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEventScanner.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEventScanner.java index c3d372fb..f1835ba1 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEventScanner.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/OnEventScanner.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/ScannerEngine.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/ScannerEngine.java index 99083f57..e7f717db 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/ScannerEngine.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/annotation/ScannerEngine.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/AuthorizeHandler.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/AuthorizeHandler.java index 8586a2f8..d2ac24ea 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/AuthorizeHandler.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/AuthorizeHandler.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientHead.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientHead.java index 6ae4db0c..6fac2dbf 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientHead.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientHead.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,7 @@ import java.util.Queue; import java.util.Set; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -52,7 +54,6 @@ import io.netty.channel.ChannelFutureListener; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.util.AttributeKey; -import io.netty.util.internal.PlatformDependent; public class ClientHead { @@ -61,7 +62,7 @@ public class ClientHead { public static final AttributeKey CLIENT = AttributeKey.valueOf("client"); private final AtomicBoolean disconnected = new AtomicBoolean(); - private final Map namespaceClients = PlatformDependent.newConcurrentHashMap(); + private final Map namespaceClients = new ConcurrentHashMap<>(); private final Map channels = new HashMap(2); private final HandshakeData handshakeData; private final UUID sessionId; @@ -124,7 +125,7 @@ public void releasePollingChannel(Channel channel) { clientsBox.remove(channel); state.update(null); } - } catch (Throwable e) { + } catch (Exception e) { log.error("Failed to release polling channel for session: {}", sessionId, e); } } @@ -141,7 +142,7 @@ public void cancelPing() { try { SchedulerKey key = new SchedulerKey(Type.PING, sessionId); scheduler.cancel(key); - } catch (Throwable e) { + } catch (Exception e) { log.error("Failed to cancel ping task for session: {}", sessionId, e); } } @@ -149,7 +150,7 @@ public void cancelPingTimeout() { try { SchedulerKey key = new SchedulerKey(Type.PING_TIMEOUT, sessionId); scheduler.cancel(key); - } catch (Throwable e) { + } catch (Exception e) { log.error("Failed to cancel ping timeout task for session: {}", sessionId, e); } } diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientsBox.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientsBox.java index c47e3beb..fd58ff73 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientsBox.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/ClientsBox.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,16 +18,16 @@ import java.util.Map; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import com.corundumstudio.socketio.HandshakeData; import io.netty.channel.Channel; -import io.netty.util.internal.PlatformDependent; public class ClientsBox { - private final Map uuid2clients = PlatformDependent.newConcurrentHashMap(); - private final Map channel2clients = PlatformDependent.newConcurrentHashMap(); + private final Map uuid2clients = new ConcurrentHashMap<>(); + private final Map channel2clients = new ConcurrentHashMap<>(); // TODO use storeFactory public HandshakeData getHandshakeData(UUID sessionId) { diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/EncoderHandler.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/EncoderHandler.java index 0e3af311..f4b276a3 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/EncoderHandler.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/EncoderHandler.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/InPacketHandler.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/InPacketHandler.java index d408834e..071157cb 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/InPacketHandler.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/InPacketHandler.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/PacketListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/PacketListener.java index 38e87c54..21dede08 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/PacketListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/PacketListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SocketIOException.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SocketIOException.java index 29c46116..a3bd1900 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SocketIOException.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SocketIOException.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SuccessAuthorizationListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SuccessAuthorizationListener.java index 8eb8bde4..ebf5bb84 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SuccessAuthorizationListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/SuccessAuthorizationListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/TransportState.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/TransportState.java index 6596cac8..4e5ae5c5 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/TransportState.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/TransportState.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/WrongUrlHandler.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/WrongUrlHandler.java index a1eda30b..0d23d65d 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/WrongUrlHandler.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/handler/WrongUrlHandler.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ClientListeners.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ClientListeners.java index 98a328bc..a3d6c0b6 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ClientListeners.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ClientListeners.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ConnectListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ConnectListener.java index 407fb3f0..87b29dd1 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ConnectListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ConnectListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DataListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DataListener.java index 345d3c6a..478ee717 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DataListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DataListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DefaultExceptionListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DefaultExceptionListener.java index 6a58eaf1..88c5ba1c 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DefaultExceptionListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DefaultExceptionListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DisconnectListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DisconnectListener.java index 2cee37b1..686e4c52 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DisconnectListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/DisconnectListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/EventInterceptor.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/EventInterceptor.java index c6934627..891337d3 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/EventInterceptor.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/EventInterceptor.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListener.java index cf6fa5d6..d29893f8 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListenerAdapter.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListenerAdapter.java index 29fa750d..511152fd 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListenerAdapter.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/ExceptionListenerAdapter.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/MultiTypeEventListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/MultiTypeEventListener.java index 84c0b2ef..b9fd0167 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/MultiTypeEventListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/MultiTypeEventListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PingListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PingListener.java index 3a4ffd04..0a3cac7b 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PingListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PingListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PongListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PongListener.java index 6e065a2d..a1c6d02d 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PongListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/listener/PongListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpErrorMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpErrorMessage.java index c6bfcd0e..bd8b143f 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpErrorMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpErrorMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpMessage.java index fc80742a..6ee6fd07 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/HttpMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/OutPacketMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/OutPacketMessage.java index ef94d31b..8701bcfb 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/OutPacketMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/OutPacketMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/PacketsMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/PacketsMessage.java index 22a78e31..2484811c 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/PacketsMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/PacketsMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHROptionsMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHROptionsMessage.java index 7701b1e0..e0541c10 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHROptionsMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHROptionsMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHRPostMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHRPostMessage.java index d4aa008a..c7256970 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHRPostMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/messages/XHRPostMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterable.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterable.java index d3175a25..e6576a71 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterable.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterable.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterator.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterator.java index 26b2dce4..29a086a2 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterator.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/CompositeIterator.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/IterableCollection.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/IterableCollection.java index e3ec5d4f..5fe255c5 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/IterableCollection.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/misc/IterableCollection.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/EventEntry.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/EventEntry.java index 581335e8..475c41e4 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/EventEntry.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/EventEntry.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java index 4649bfe9..b5caabeb 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +25,13 @@ import java.util.Queue; import java.util.Set; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.corundumstudio.socketio.AckMode; import com.corundumstudio.socketio.AckRequest; import com.corundumstudio.socketio.AuthTokenListener; @@ -55,9 +60,6 @@ import com.corundumstudio.socketio.store.pubsub.PubSubType; import com.corundumstudio.socketio.transport.NamespaceClient; -import io.netty.util.internal.PlatformDependent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Hub object for all clients in one namespace. @@ -72,7 +74,7 @@ public class Namespace implements SocketIONamespace { public static final String DEFAULT_NAME = ""; private final ScannerEngine engine = new ScannerEngine(); - private final ConcurrentMap> eventListeners = PlatformDependent.newConcurrentHashMap(); + private final ConcurrentMap> eventListeners = new ConcurrentHashMap<>(); private final Queue connectListeners = new ConcurrentLinkedQueue(); private final Queue disconnectListeners = new ConcurrentLinkedQueue(); private final Queue pingListeners = new ConcurrentLinkedQueue(); @@ -81,9 +83,9 @@ public class Namespace implements SocketIONamespace { private final Queue authDataInterceptors = new ConcurrentLinkedQueue<>(); - private final Map allClients = PlatformDependent.newConcurrentHashMap(); - private final ConcurrentMap> roomClients = PlatformDependent.newConcurrentHashMap(); - private final ConcurrentMap> clientRooms = PlatformDependent.newConcurrentHashMap(); + private final Map allClients = new ConcurrentHashMap<>(); + private final ConcurrentMap> roomClients = new ConcurrentHashMap<>(); + private final ConcurrentMap> clientRooms = new ConcurrentHashMap<>(); private final String name; private final AckMode ackMode; @@ -374,7 +376,7 @@ public void dispatch(String room, Packet packet) { private void join(ConcurrentMap> map, K key, V value) { Set clients = map.get(key); if (clients == null) { - clients = Collections.newSetFromMap(PlatformDependent.newConcurrentHashMap()); + clients = Collections.newSetFromMap(new ConcurrentHashMap<>()); Set oldClients = map.putIfAbsent(key, clients); if (oldClients != null) { clients = oldClients; diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/NamespacesHub.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/NamespacesHub.java index c0c8d1e4..76671a6a 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/NamespacesHub.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/namespace/NamespacesHub.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +19,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import com.corundumstudio.socketio.Configuration; @@ -25,11 +27,9 @@ import com.corundumstudio.socketio.SocketIONamespace; import com.corundumstudio.socketio.misc.CompositeIterable; -import io.netty.util.internal.PlatformDependent; - public class NamespacesHub { - private final ConcurrentMap namespaces = PlatformDependent.newConcurrentHashMap(); + private final ConcurrentMap namespaces = new ConcurrentHashMap<>(); private final Configuration configuration; public NamespacesHub(Configuration configuration) { diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/nativeio/TransportType.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/nativeio/TransportType.java new file mode 100644 index 00000000..b247fced --- /dev/null +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/nativeio/TransportType.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov + * + * 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 + * + * http://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. + */ +package com.corundumstudio.socketio.nativeio; + +public enum TransportType { + AUTO, // select the best available, io_uring -> epoll -> kqueue -> nio + NIO, // JVM default + EPOLL, // Linux + KQUEUE, // BSD / macOS + IO_URING; // Linux 5.1+, recommended production version 5.15+ (LTS) +} diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AckArgs.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AckArgs.java index 7198730c..d6ae6eaf 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AckArgs.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AckArgs.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AuthPacket.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AuthPacket.java index 78b81351..7398b20e 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AuthPacket.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/AuthPacket.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/ConnPacket.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/ConnPacket.java index b3acabd7..245ed243 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/ConnPacket.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/ConnPacket.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/EngineIOVersion.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/EngineIOVersion.java index 1fc92f82..676943b4 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/EngineIOVersion.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/EngineIOVersion.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Event.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Event.java index d88add4d..36aad393 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Event.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Event.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JacksonJsonSupport.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JacksonJsonSupport.java index 97d97cd0..6495bf56 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JacksonJsonSupport.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JacksonJsonSupport.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +27,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,7 +66,6 @@ import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; -import io.netty.util.internal.PlatformDependent; public class JacksonJsonSupport implements JsonSupport { @@ -166,7 +167,7 @@ protected class EventDeserializer extends StdDeserializer { private static final long serialVersionUID = 8178797221017768689L; - final Map>> eventMapping = PlatformDependent.newConcurrentHashMap(); + final Map>> eventMapping = new ConcurrentHashMap<>(); protected EventDeserializer() { diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JsonSupport.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JsonSupport.java index ae85b090..2a31a68c 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JsonSupport.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/JsonSupport.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Packet.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Packet.java index a0c017fc..bb04950b 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Packet.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/Packet.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketDecoder.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketDecoder.java index f2a46481..09e52ef1 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketDecoder.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketDecoder.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketEncoder.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketEncoder.java index 551bab63..205e79e3 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketEncoder.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketEncoder.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketType.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketType.java index 393d8021..2586058d 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketType.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/PacketType.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/UTF8CharsScanner.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/UTF8CharsScanner.java index 9dcd41d4..48773611 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/UTF8CharsScanner.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/protocol/UTF8CharsScanner.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/CancelableScheduler.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/CancelableScheduler.java index fbbdb7ba..f6635f54 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/CancelableScheduler.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/CancelableScheduler.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelScheduler.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelScheduler.java index 6afe4ca3..0d220db2 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelScheduler.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelScheduler.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ package com.corundumstudio.socketio.scheduler; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; @@ -23,11 +25,10 @@ import io.netty.util.HashedWheelTimer; import io.netty.util.Timeout; import io.netty.util.TimerTask; -import io.netty.util.internal.PlatformDependent; public class HashedWheelScheduler implements CancelableScheduler { - private final Map scheduledFutures = PlatformDependent.newConcurrentHashMap(); + private final Map scheduledFutures = new ConcurrentHashMap<>(); private final HashedWheelTimer executorService; public HashedWheelScheduler() { diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutScheduler.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutScheduler.java index 436505cf..ae8c8168 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutScheduler.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutScheduler.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,7 @@ package com.corundumstudio.socketio.scheduler; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; @@ -32,11 +34,10 @@ import io.netty.util.HashedWheelTimer; import io.netty.util.Timeout; import io.netty.util.TimerTask; -import io.netty.util.internal.PlatformDependent; public class HashedWheelTimeoutScheduler implements CancelableScheduler { - private final ConcurrentMap scheduledFutures = PlatformDependent.newConcurrentHashMap(); + private final ConcurrentMap scheduledFutures = new ConcurrentHashMap<>(); private final HashedWheelTimer executorService; private volatile ChannelHandlerContext ctx; diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/SchedulerKey.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/SchedulerKey.java index e097b490..256ae43f 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/SchedulerKey.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/scheduler/SchedulerKey.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastPubSubStore.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastPubSubStore.java index 035b0b42..9bde63f1 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastPubSubStore.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastPubSubStore.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +17,11 @@ package com.corundumstudio.socketio.store; import java.util.Queue; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; -import java.util.UUID; + import com.corundumstudio.socketio.store.pubsub.PubSubListener; import com.corundumstudio.socketio.store.pubsub.PubSubMessage; import com.corundumstudio.socketio.store.pubsub.PubSubStore; @@ -27,16 +30,13 @@ import com.hazelcast.topic.ITopic; -import io.netty.util.internal.PlatformDependent; - - public class HazelcastPubSubStore implements PubSubStore { private final HazelcastInstance hazelcastPub; private final HazelcastInstance hazelcastSub; private final Long nodeId; - private final ConcurrentMap> map = PlatformDependent.newConcurrentHashMap(); + private final ConcurrentMap> map = new ConcurrentHashMap<>(); public HazelcastPubSubStore(HazelcastInstance hazelcastPub, HazelcastInstance hazelcastSub, Long nodeId) { this.hazelcastPub = hazelcastPub; @@ -76,6 +76,9 @@ public void subscribe(PubSubType type, final PubSubLis public void unsubscribe(PubSubType type) { String name = type.toString(); Queue regIds = map.remove(name); + if (regIds == null || regIds.isEmpty()) { + return; + } ITopic topic = hazelcastSub.getTopic(name); for (UUID id : regIds) { topic.removeMessageListener(id); diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStore.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStore.java index e64ef42f..73652368 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStore.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStore.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStoreFactory.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStoreFactory.java index 3d5e775f..8aaa4dd1 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStoreFactory.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/HazelcastStoreFactory.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryPubSubStore.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryPubSubStore.java index d724e0bf..24cbc0ad 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryPubSubStore.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryPubSubStore.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStore.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStore.java index b6727f16..7d416c3f 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStore.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStore.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +17,11 @@ package com.corundumstudio.socketio.store; import java.util.Map; - -import io.netty.util.internal.PlatformDependent; +import java.util.concurrent.ConcurrentHashMap; public class MemoryStore implements Store { - private final Map store = PlatformDependent.newConcurrentHashMap(); + private final Map store = new ConcurrentHashMap<>(); @Override public void set(String key, Object value) { diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStoreFactory.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStoreFactory.java index b1cebc20..cc2cdaeb 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStoreFactory.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/MemoryStoreFactory.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +18,11 @@ import java.util.Map; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import com.corundumstudio.socketio.store.pubsub.BaseStoreFactory; import com.corundumstudio.socketio.store.pubsub.PubSubStore; -import io.netty.util.internal.PlatformDependent; - public class MemoryStoreFactory extends BaseStoreFactory { private final MemoryPubSubStore pubSubMemoryStore = new MemoryPubSubStore(); @@ -48,7 +48,7 @@ public String toString() { @Override public Map createMap(String name) { - return PlatformDependent.newConcurrentHashMap(); + return new ConcurrentHashMap<>(); } } diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonPubSubStore.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonPubSubStore.java index e381ec83..0f695759 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonPubSubStore.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonPubSubStore.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ package com.corundumstudio.socketio.store; import java.util.Queue; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; @@ -28,15 +30,13 @@ import com.corundumstudio.socketio.store.pubsub.PubSubStore; import com.corundumstudio.socketio.store.pubsub.PubSubType; -import io.netty.util.internal.PlatformDependent; - public class RedissonPubSubStore implements PubSubStore { private final RedissonClient redissonPub; private final RedissonClient redissonSub; private final Long nodeId; - private final ConcurrentMap> map = PlatformDependent.newConcurrentHashMap(); + private final ConcurrentMap> map = new ConcurrentHashMap<>(); public RedissonPubSubStore(RedissonClient redissonPub, RedissonClient redissonSub, Long nodeId) { this.redissonPub = redissonPub; diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStore.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStore.java index 3606a95b..81fda49f 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStore.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStore.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStoreFactory.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStoreFactory.java index 9704127e..fdea05d0 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStoreFactory.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/RedissonStoreFactory.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/Store.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/Store.java index 75a0e84c..86bd88ed 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/Store.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/Store.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/StoreFactory.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/StoreFactory.java index 411bf753..13491618 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/StoreFactory.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/StoreFactory.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BaseStoreFactory.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BaseStoreFactory.java index b745dfa1..453567bc 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BaseStoreFactory.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BaseStoreFactory.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BulkJoinLeaveMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BulkJoinLeaveMessage.java index 3f17febf..e6a9c8ba 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BulkJoinLeaveMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/BulkJoinLeaveMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/ConnectMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/ConnectMessage.java index 4e6df62b..c8963691 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/ConnectMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/ConnectMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DisconnectMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DisconnectMessage.java index 2801cf63..ea1f0a46 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DisconnectMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DisconnectMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DispatchMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DispatchMessage.java index 302f8119..86434e1e 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DispatchMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/DispatchMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/JoinLeaveMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/JoinLeaveMessage.java index 93b24503..155d00a1 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/JoinLeaveMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/JoinLeaveMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubListener.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubListener.java index 8ba4846c..0ecb762e 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubListener.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubListener.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubMessage.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubMessage.java index 1d9bcd5e..71369e0b 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubMessage.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubStore.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubStore.java index c25f340d..4d48108e 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubStore.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubStore.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubType.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubType.java index 28028a09..b5b2dda6 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubType.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/store/pubsub/PubSubType.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/NamespaceClient.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/NamespaceClient.java index 3c1e0f64..f379b27e 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/NamespaceClient.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/NamespaceClient.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/PollingTransport.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/PollingTransport.java index 988b8cf2..bd662b71 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/PollingTransport.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/PollingTransport.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java index adf4d275..c6b28256 100644 --- a/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java +++ b/netty-socketio-core/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/main/java/module-info.java b/netty-socketio-core/src/main/java/module-info.java index 826ee296..8eccaef3 100644 --- a/netty-socketio-core/src/main/java/module-info.java +++ b/netty-socketio-core/src/main/java/module-info.java @@ -12,7 +12,7 @@ exports com.corundumstudio.socketio.store; exports com.corundumstudio.socketio.store.pubsub; exports com.corundumstudio.socketio.transport; - + exports com.corundumstudio.socketio.nativeio; requires com.fasterxml.jackson.core; requires com.fasterxml.jackson.annotation; requires com.fasterxml.jackson.databind; diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/JoinIteratorsTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/JoinIteratorsTest.java index a31d0b5b..fc64dab0 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/JoinIteratorsTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/JoinIteratorsTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/AnnotationTestBase.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/AnnotationTestBase.java index cc02ba16..014df394 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/AnnotationTestBase.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/AnnotationTestBase.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnConnectScannerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnConnectScannerTest.java index cf8d9908..5e5ca4e7 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnConnectScannerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnConnectScannerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnDisconnectScannerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnDisconnectScannerTest.java index 171effe0..b76313d7 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnDisconnectScannerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnDisconnectScannerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnEventScannerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnEventScannerTest.java index 07601747..c271f5e5 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnEventScannerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/OnEventScannerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/ScannerEngineTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/ScannerEngineTest.java index 9bb9595f..5572ed6d 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/ScannerEngineTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/annotation/ScannerEngineTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/LongToBytesBenchmark.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/LongToBytesBenchmark.java index d8dc295d..f0f2efcb 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/LongToBytesBenchmark.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/LongToBytesBenchmark.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/PreprocessJsonBenchmark.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/PreprocessJsonBenchmark.java index 5e4fc9c9..17b772f0 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/PreprocessJsonBenchmark.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/benchmark/PreprocessJsonBenchmark.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/AuthorizeHandlerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/AuthorizeHandlerTest.java index 16f32aa9..083d2543 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/AuthorizeHandlerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/AuthorizeHandlerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/ClientPacketTestUtils.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/ClientPacketTestUtils.java index f8186a20..41463cd0 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/ClientPacketTestUtils.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/ClientPacketTestUtils.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/EncoderHandlerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/EncoderHandlerTest.java index 82d1b959..d2eda304 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/EncoderHandlerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/EncoderHandlerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/InPacketHandlerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/InPacketHandlerTest.java index a533394c..a2af676b 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/InPacketHandlerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/InPacketHandlerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/PacketListenerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/PacketListenerTest.java index 55fa7592..2ff11abc 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/PacketListenerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/handler/PacketListenerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AbstractSocketIOIntegrationTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AbstractSocketIOIntegrationTest.java index 3288d578..b9d54c85 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AbstractSocketIOIntegrationTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AbstractSocketIOIntegrationTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,21 +16,16 @@ */ package com.corundumstudio.socketio.integration; +import java.net.ServerSocket; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.redisson.Redisson; -import org.redisson.api.RedissonClient; -import org.redisson.config.Config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.corundumstudio.socketio.Configuration; import com.corundumstudio.socketio.SocketIOServer; -import com.corundumstudio.socketio.store.CustomizedRedisContainer; -import com.corundumstudio.socketio.store.RedissonStoreFactory; import com.github.javafaker.Faker; import io.socket.client.IO; @@ -54,10 +50,6 @@ public abstract class AbstractSocketIOIntegrationTest { private int serverPort; private static final String SERVER_HOST = "localhost"; - private static final int BASE_PORT = 9000; - private static final int PORT_RANGE = 2000; // Increased range for better distribution - private static final AtomicInteger PORT_COUNTER = new AtomicInteger(0); - private static final int MAX_PORT_RETRIES = 30; /** * Get the current server port for this test instance @@ -102,45 +94,12 @@ protected Socket createClient(String namespace) { } } - /** - * Allocate a unique port for this test instance. - * Uses atomic counter to ensure thread-safe port allocation. - */ - private synchronized int allocatePort() { - int portIndex = PORT_COUNTER.getAndIncrement(); - int port = BASE_PORT + (portIndex % PORT_RANGE); - - // If we've used all ports in the range, reset counter - if (portIndex >= PORT_RANGE) { - PORT_COUNTER.set(0); - } - return port; - } - /** * Find an available port with retry mechanism */ private int findAvailablePort() throws Exception { - for (int attempt = 0; attempt < MAX_PORT_RETRIES; attempt++) { - int port = allocatePort(); - if (isPortAvailable(port)) { - return port; - } - // Wait a bit before retrying - Thread.sleep(1000); - log.info("Waiting for port {} to become available", port); - } - throw new RuntimeException("Could not find available port after " + MAX_PORT_RETRIES + " attempts"); - } - - /** - * Check if a port is available - */ - private boolean isPortAvailable(int port) { - try (java.net.ServerSocket serverSocket = new java.net.ServerSocket(port)) { - return true; - } catch (Exception e) { - return false; + try (ServerSocket socket = new ServerSocket(0)) { // using zero will auto assign port + return socket.getLocalPort(); } } diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AckCallbacksTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AckCallbacksTest.java index 55f2ed63..22a8f39c 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AckCallbacksTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AckCallbacksTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AuthPayloadTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AuthPayloadTest.java index afc88747..8d36c41a 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AuthPayloadTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/AuthPayloadTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BasicConnectionTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BasicConnectionTest.java index 48ab8e16..290a348e 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BasicConnectionTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BasicConnectionTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BinaryDataTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BinaryDataTest.java index 8f060368..2484045e 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BinaryDataTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/BinaryDataTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/ClientDisconnectionTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/ClientDisconnectionTest.java index f2ace9a8..81ae860d 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/ClientDisconnectionTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/ClientDisconnectionTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/HeartbeatTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/HeartbeatTest.java index 20517658..3fdcbfe6 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/HeartbeatTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/HeartbeatTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/LargePayloadTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/LargePayloadTest.java index 49b12a23..b409e383 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/LargePayloadTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/LargePayloadTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomBroadcastTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomBroadcastTest.java index f7bc29c2..6920c715 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomBroadcastTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomBroadcastTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomManagementTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomManagementTest.java index 0b8c6a4a..0ec51f46 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomManagementTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/RoomManagementTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/SessionRecoveryTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/SessionRecoveryTest.java index e05e7751..be839164 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/SessionRecoveryTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/SessionRecoveryTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/TransportUpgradeTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/TransportUpgradeTest.java index 894026c5..09d2ad47 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/TransportUpgradeTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/integration/TransportUpgradeTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/BaseNamespaceTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/BaseNamespaceTest.java index 4dff3c32..6d0c0fe7 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/BaseNamespaceTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/BaseNamespaceTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/EventEntryTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/EventEntryTest.java index 3da5a2ec..17fe619e 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/EventEntryTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/EventEntryTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceEventHandlingTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceEventHandlingTest.java index ccbf2f3c..9eebdc61 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceEventHandlingTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceEventHandlingTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceRoomManagementTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceRoomManagementTest.java index 690cc8be..5614b5aa 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceRoomManagementTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceRoomManagementTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceTest.java index e1f92179..e25c5d63 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespaceTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespacesHubTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespacesHubTest.java index 1074a69c..be0ef6bf 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespacesHubTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/namespace/NamespacesHubTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AckArgsTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AckArgsTest.java index 5827ea17..4a3f4c9a 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AckArgsTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AckArgsTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AuthPacketTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AuthPacketTest.java index 920d37a4..0c69f24d 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AuthPacketTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/AuthPacketTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/BaseProtocolTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/BaseProtocolTest.java index e5736492..9b70c536 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/BaseProtocolTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/BaseProtocolTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/ConnPacketTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/ConnPacketTest.java index da4fd46e..8d2e023d 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/ConnPacketTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/ConnPacketTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EngineIOVersionTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EngineIOVersionTest.java index 529fd1e5..9950ad19 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EngineIOVersionTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EngineIOVersionTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EventTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EventTest.java index a5149aec..c16531ff 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EventTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/EventTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/JsonSupportTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/JsonSupportTest.java index fab9c3f4..52606f0d 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/JsonSupportTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/JsonSupportTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientTest.java index e9e0a63e..e24f130e 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientUtil.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientUtil.java index 0e3e9855..8b62e23d 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientUtil.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/NativeSocketIOClientUtil.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketDecoderTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketDecoderTest.java index a0c938d0..e7ce019d 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketDecoderTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketDecoderTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketEncoderTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketEncoderTest.java index 0d6c6c2d..527e21ae 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketEncoderTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketEncoderTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTest.java index 9b3793ed..34bad4a6 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTypeTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTypeTest.java index 7b9cb8f4..b20828ac 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTypeTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/PacketTypeTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/UTF8CharsScannerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/UTF8CharsScannerTest.java index 412bbcc5..fdf7ae25 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/UTF8CharsScannerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/protocol/UTF8CharsScannerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelSchedulerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelSchedulerTest.java index c9253649..884cb538 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelSchedulerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelSchedulerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java index 4ea83119..2a2be5de 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/HashedWheelTimeoutSchedulerTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/SchedulerKeyTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/SchedulerKeyTest.java index c035aeef..ccd4a142 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/SchedulerKeyTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/scheduler/SchedulerKeyTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/AbstractStoreTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/AbstractStoreTest.java index 3f8c7ae8..886f63ca 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/AbstractStoreTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/AbstractStoreTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +17,11 @@ package com.corundumstudio.socketio.store; import java.io.Serializable; +import java.util.Objects; import java.util.UUID; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -37,13 +40,18 @@ public abstract class AbstractStoreTest { protected Store store; protected UUID sessionId; - protected GenericContainer container; + protected static GenericContainer container; @BeforeEach public void setUp() throws Exception { sessionId = UUID.randomUUID(); - container = createContainer(); - container.start(); + if (container == null) { + container = createContainer(); + } + if (!container.isRunning()) { + container.start(); + } + store = createStore(sessionId); } @@ -53,9 +61,14 @@ public void tearDown() throws Exception { // Clean up store data cleanupStore(); } - if (container != null && container.isRunning()) { - container.stop(); + } + + @AfterAll + public static void cleanup() { + if (container != null) { + container.close(); } + } /** @@ -73,6 +86,7 @@ public void tearDown() throws Exception { */ protected abstract void cleanupStore(); + @Test public void testBasicOperations() { // Test set and get @@ -173,6 +187,8 @@ public void testConcurrentAccess() throws InterruptedException { } } + + /** * Test object for complex object testing */ @@ -209,14 +225,12 @@ public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; TestObject that = (TestObject) obj; - return value == that.value && (name != null ? name.equals(that.name) : that.name == null); + return value == that.value && (Objects.equals(name, that.name)); } @Override public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + value; - return result; + return Objects.hash(name, value); } } } diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedHazelcastContainer.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedHazelcastContainer.java index 308b9a39..4ca5f92e 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedHazelcastContainer.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedHazelcastContainer.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,78 +16,61 @@ */ package com.corundumstudio.socketio.store; -import java.util.concurrent.TimeUnit; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; -import com.github.dockerjava.api.command.InspectContainerResponse; +import java.time.Duration; /** - * Customized Hazelcast container for testing purposes. + * Optimized Hazelcast container for testing. + * + * - No artificial sleeps + * - No polling loops + * - Uses Testcontainers' built-in readiness checks + * - Much faster test execution */ public class CustomizedHazelcastContainer extends GenericContainer { + private static final Logger log = LoggerFactory.getLogger(CustomizedHazelcastContainer.class); + public static final int HAZELCAST_PORT = 5701; - /** - * Default constructor that initializes the Hazelcast container with the official Hazelcast image. - */ public CustomizedHazelcastContainer() { super("hazelcast/hazelcast:5.6.0"); } @Override protected void configure() { + withExposedPorts(HAZELCAST_PORT); + + // Map custom test config file withEnv("JVM_OPTS", "-Dhazelcast.config=/opt/hazelcast/config_ext/hazelcast.xml"); - withClasspathResourceMapping("hazelcast-test-config.xml", - "/opt/hazelcast/config_ext/hazelcast.xml", - org.testcontainers.containers.BindMode.READ_ONLY); - } + withClasspathResourceMapping( + "hazelcast-test-config.xml", + "/opt/hazelcast/config_ext/hazelcast.xml", + BindMode.READ_ONLY + ); - @Override - protected void containerIsStarted(InspectContainerResponse containerInfo) { - try { - // Wait for Hazelcast to be ready - TimeUnit.SECONDS.sleep(15); - - // Check if Hazelcast is responding - ExecResult result = null; - int attempts = 0; - while (attempts < 20) { - try { - result = execInContainer("sh", "-c", "netstat -an | grep " + HAZELCAST_PORT + " | grep LISTEN"); - if (result.getExitCode() == 0 && result.getStdout().contains("LISTEN")) { - log.info("Hazelcast is ready and listening on port {}", HAZELCAST_PORT); - break; - } - } catch (Exception e) { - // Ignore and retry - } - - attempts++; - TimeUnit.SECONDS.sleep(2); - log.info("Waiting for Hazelcast to be ready, attempt {}", attempts); - } - - if (attempts >= 20) { - log.info("Hazelcast container started but may not be fully ready"); - } - } catch (Exception e) { - throw new RuntimeException("Failed to start Hazelcast container", e); - } + // Proper readiness check (fast, reliable, no sleeps) + waitingFor( + Wait.forListeningPort() + .withStartupTimeout(Duration.ofSeconds(300)) + ); } @Override public void start() { super.start(); - log.info("Hazelcast started at port: {}", getHazelcastPort()); + log.info("Hazelcast started at port {}", getHazelcastPort()); } @Override public void stop() { + log.info("Hazelcast shutting down..."); super.stop(); log.info("Hazelcast stopped"); } diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedRedisContainer.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedRedisContainer.java index 18804b4d..af94d280 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedRedisContainer.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/CustomizedRedisContainer.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreFactoryTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreFactoryTest.java index 74b55383..4e8b911b 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreFactoryTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreFactoryTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +19,7 @@ import java.util.Map; import java.util.UUID; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -31,9 +33,7 @@ import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.when; /** @@ -41,13 +41,13 @@ */ public class HazelcastStoreFactoryTest extends StoreFactoryTest { - private GenericContainer container; + private static GenericContainer container; private HazelcastInstance hazelcastInstance; private AutoCloseable closeableMocks; @Override protected StoreFactory createStoreFactory() throws Exception { - container = new CustomizedHazelcastContainer(); + container = new CustomizedHazelcastContainer().withReuse(true); container.start(); CustomizedHazelcastContainer customizedHazelcastContainer = (CustomizedHazelcastContainer) container; @@ -72,6 +72,11 @@ public void tearDown() throws Exception { if (hazelcastInstance != null) { hazelcastInstance.shutdown(); } + + } + + @AfterAll + public static void afterAll() throws Exception { if (container != null && container.isRunning()) { container.stop(); } @@ -84,7 +89,7 @@ public void testHazelcastSpecificFeatures() { Store store = storeFactory.createStore(sessionId); assertNotNull(store, "Store should not be null"); - assertTrue(store instanceof HazelcastStore, "Store should be HazelcastStore"); + assertInstanceOf(HazelcastStore.class, store, "Store should be HazelcastStore"); // Test that the store works with Hazelcast store.set("hazelcastKey", "hazelcastValue"); @@ -96,7 +101,7 @@ public void testHazelcastPubSubStore() { PubSubStore pubSubStore = storeFactory.pubSubStore(); assertNotNull(pubSubStore, "PubSubStore should not be null"); - assertTrue(pubSubStore instanceof HazelcastPubSubStore, "PubSubStore should be HazelcastStore"); + assertInstanceOf(HazelcastPubSubStore.class, pubSubStore, "PubSubStore should be HazelcastStore"); } @Test @@ -142,6 +147,6 @@ public void testOnDisconnect() { // Verify the Hazelcast map is destroyed // After destroy, the map should be empty or not accessible IMap map = hazelcastInstance.getMap(sessionId.toString()); - assertTrue(map.isEmpty() || map.size() == 0, "Map should be empty after destroy"); + assertTrue(map.isEmpty(), "Map should be empty after destroy"); } } diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreTest.java index 6c54dda0..9169a551 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/HazelcastStoreTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +37,7 @@ public class HazelcastStoreTest extends AbstractStoreTest { @Override protected GenericContainer createContainer() { - return new CustomizedHazelcastContainer(); + return new CustomizedHazelcastContainer().withReuse(true); } @Override @@ -54,11 +55,15 @@ protected Store createStore(UUID sessionId) throws Exception { @Override protected void cleanupStore() { + if (store != null) { + store.destroy(); + } if (hazelcastInstance != null) { hazelcastInstance.shutdown(); } } + @Test public void testHazelcastSpecificFeatures() { // Test that the store is actually using Hazelcast diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreFactoryTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreFactoryTest.java index 05671dc9..f2fb3ceb 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreFactoryTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreFactoryTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreTest.java index ea0cd5f2..2d27ce63 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/MemoryStoreTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreFactoryTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreFactoryTest.java index 9fbf1342..722a4370 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreFactoryTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreFactoryTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +19,7 @@ import java.util.Map; import java.util.UUID; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -41,13 +43,13 @@ */ public class RedissonStoreFactoryTest extends StoreFactoryTest { - private GenericContainer container; + private static GenericContainer container; private RedissonClient redissonClient; private AutoCloseable closeableMocks; @Override protected StoreFactory createStoreFactory() throws Exception { - container = new CustomizedRedisContainer(); + container = new CustomizedRedisContainer().withReuse(true); container.start(); CustomizedRedisContainer customizedRedisContainer = (CustomizedRedisContainer) container; @@ -70,6 +72,11 @@ public void tearDown() throws Exception { if (redissonClient != null) { redissonClient.shutdown(); } + + } + + @AfterAll + public static void afterAll() throws Exception { if (container != null && container.isRunning()) { container.stop(); } diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreTest.java index bde9f1a9..19e88baa 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/RedissonStoreTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +39,7 @@ public class RedissonStoreTest extends AbstractStoreTest { @Override protected GenericContainer createContainer() { - return new CustomizedRedisContainer(); + return new CustomizedRedisContainer().withReuse(true); } @Override @@ -55,10 +56,12 @@ protected Store createStore(UUID sessionId) throws Exception { @Override protected void cleanupStore() { if (redissonClient != null) { + redissonClient.getKeys().flushall(); redissonClient.shutdown(); } } + @Test public void testRedissonSpecificFeatures() { // Test that the store is actually using Redisson diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/StoreFactoryTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/StoreFactoryTest.java index 53e79c6e..5fa752f4 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/StoreFactoryTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/StoreFactoryTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,12 +30,7 @@ import com.corundumstudio.socketio.protocol.JsonSupport; import com.corundumstudio.socketio.store.pubsub.PubSubStore; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * Test class for StoreFactory implementations @@ -77,7 +73,7 @@ public void testCreateStore() { Store store = storeFactory.createStore(sessionId); assertNotNull(store, "Store should not be null"); - assertTrue(store instanceof Store, "Store should implement Store interface"); + assertInstanceOf(Store.class, store, "Store should implement Store interface"); } @Test @@ -85,7 +81,7 @@ public void testCreatePubSubStore() { PubSubStore pubSubStore = storeFactory.pubSubStore(); assertNotNull(pubSubStore, "PubSubStore should not be null"); - assertTrue(pubSubStore instanceof PubSubStore, "PubSubStore should implement PubSubStore interface"); + assertInstanceOf(PubSubStore.class, pubSubStore, "PubSubStore should implement PubSubStore interface"); } @Test @@ -94,7 +90,7 @@ public void testCreateMap() { Map map = storeFactory.createMap(mapName); assertNotNull(map, "Map should not be null"); - assertTrue(map instanceof Map, "Map should implement Map interface"); + assertInstanceOf(Map.class, map, "Map should implement Map interface"); } @Test @@ -127,7 +123,7 @@ public void testStoreIsolation() { // Store1 should still have the data assertTrue(store1.has("isolatedKey"), "Store1 should have its data"); - assertEquals(store1.get("isolatedKey"), "store1Value", "Store1 should return its data"); + assertEquals("store1Value", store1.get("isolatedKey"), "Store1 should return its data"); } @Test diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/AbstractPubSubStoreTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/AbstractPubSubStoreTest.java index 8017ea59..5f3eefba 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/AbstractPubSubStoreTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/AbstractPubSubStoreTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/HazelcastPubSubStoreTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/HazelcastPubSubStoreTest.java index c0366da6..4bb85e83 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/HazelcastPubSubStoreTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/HazelcastPubSubStoreTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/RedissonPubSubStoreTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/RedissonPubSubStoreTest.java index e95e6058..79f28450 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/RedissonPubSubStoreTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/RedissonPubSubStoreTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/TestMessage.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/TestMessage.java index da773805..721403b0 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/TestMessage.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/store/pubsub/TestMessage.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/HttpTransportTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/HttpTransportTest.java index 407dadb3..3601509c 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/HttpTransportTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/HttpTransportTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +32,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,25 +48,27 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import io.netty.channel.ChannelHandlerContext; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import io.netty.channel.ChannelHandlerContext; + public class HttpTransportTest { private SocketIOServer server; - private ObjectMapper mapper = new ObjectMapper(); + private final ObjectMapper mapper = new ObjectMapper(); - private Pattern responseJsonMatcher = Pattern.compile("([0-9]+)(\\{.*\\})?"); + private final Pattern responseJsonMatcher = Pattern.compile("([0-9]+)(\\{.*})?"); - private Pattern multiResponsePattern = Pattern.compile("((?[0-9])(?[0-9]*)(?.+)\\x{1E})*(?[0-9])(?[0-9]*)(?.+)"); + private final Pattern multiResponsePattern = Pattern.compile("((?[0-9])(?[0-9]*)(?.+)\\x{1E})*(?[0-9])(?[0-9]*)(?.+)"); private final String packetSeparator = new String(new byte[] { 0x1e }); - private Logger logger = LoggerFactory.getLogger(HttpTransportTest.class); + private final Logger logger = LoggerFactory.getLogger(HttpTransportTest.class); @BeforeEach public void createTestServer() { @@ -125,29 +129,25 @@ public void cleanupTestServer() { /** * Creates a test server URI with the specified query parameters. - * * This method demonstrates how query parameters are passed to the Socket.IO server. * The query string will be parsed by netty-socketio and stored in HandshakeData.urlParams * for structured access during the handshake process. - * * @param query the query string (e.g., "EIO=4&transport=polling&t=Oqd9eWh") * @return URI with the specified query parameters * @throws URISyntaxException if the URI is malformed */ private URI createTestServerUri(final String query) throws URISyntaxException { - return new URI("http", null , "localhost", server.getConfiguration().getPort(), server.getConfiguration().getContext() + "/", + return new URI("http", null, "localhost", server.getConfiguration().getPort(), server.getConfiguration().getContext() + "/", query, null); } /** * Makes a Socket.IO HTTP request to the test server. - * * This method demonstrates the complete handshake process including: * - Engine.IO version specification (EIO=4) * - Transport type specification (transport=polling) * - Session ID handling (sid parameter) * - Query parameter parsing by netty-socketio - * * The query parameters in the request URI will be parsed and stored in HandshakeData.urlParams, * providing structured access to authentication tokens, user IDs, and other metadata. * @@ -160,33 +160,36 @@ private URI createTestServerUri(final String query) throws URISyntaxException { */ private String makeSocketIoRequest(final String sessionId, final String bodyForPost) throws URISyntaxException, IOException, InterruptedException { - final URI uri = createTestServerUri("EIO=4&transport=polling&t=Oqd9eWh" + (sessionId == null ? "" : "&sid=" + sessionId)); - - URLConnection con = uri.toURL().openConnection(); - HttpURLConnection http = (HttpURLConnection)con; - if (bodyForPost != null) { - http.setRequestMethod("POST"); // PUT is another valid option - http.setDoOutput(true); - } + final URI uri; + if (sessionId == null) uri = createTestServerUri("EIO=4&transport=polling&t=Oqd9eWh"); + else uri = createTestServerUri("EIO=4&transport=polling&t=Oqd9eWh" + "&sid=" + sessionId); - if (bodyForPost != null) { - byte[] out = bodyForPost.toString().getBytes(StandardCharsets.UTF_8); - http.setFixedLengthStreamingMode(out.length); - http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); - http.connect(); - try (OutputStream os = http.getOutputStream()) { - os.write(out); - } - } else { - http.connect(); - } + URLConnection con = uri.toURL().openConnection(); + HttpURLConnection http = getHttpURLConnection(bodyForPost, (HttpURLConnection) con); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(http.getInputStream(), StandardCharsets.UTF_8))) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(http.getInputStream(), StandardCharsets.UTF_8))) { return reader.lines().collect(Collectors.joining("\n")); } } - private void postMessage(final String sessionId, final String body) + private static @NotNull HttpURLConnection getHttpURLConnection(String bodyForPost, HttpURLConnection http) throws IOException { + if (bodyForPost != null) { + http.setRequestMethod("POST"); // PUT is another valid option + http.setDoOutput(true); + byte[] out = bodyForPost.getBytes(StandardCharsets.UTF_8); + http.setFixedLengthStreamingMode(out.length); + http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + http.connect(); + try (OutputStream os = http.getOutputStream()) { + os.write(out); + } + } else { + http.connect(); + } + return http; + } + + private void postMessage(final String sessionId, final String body) throws URISyntaxException, IOException, InterruptedException { final String responseStr = makeSocketIoRequest(sessionId, body); assertEquals(responseStr, "ok"); @@ -203,7 +206,7 @@ private String connectForSessionId(final String sessionId) final String firstMessage = pollForListOfResponses(sessionId)[0]; final Matcher jsonMatcher = responseJsonMatcher.matcher(firstMessage); assertTrue(jsonMatcher.find()); - assertEquals(jsonMatcher.group(1), "0"); + assertEquals("0", jsonMatcher.group(1)); final JsonNode node = mapper.readTree(jsonMatcher.group(2)); return node.get("sid").asText(); } @@ -223,14 +226,14 @@ public void testMultipleMessages() throws URISyntaxException, IOException, Inter events.add("420[\"hello\", \"world\"]"); events.add("421[\"hello\", \"socketio\"]"); events.add("422[\"hello\", \"socketio\"]"); - postMessage(sessionId, events.stream().collect(Collectors.joining(packetSeparator))); + postMessage(sessionId, String.join(packetSeparator, events)); final String[] responses = pollForListOfResponses(sessionId); - assertEquals(responses.length, 3); + assertEquals(3, responses.length); } /** * Returns a free port number on localhost. - * + *

* Heavily inspired from org.eclipse.jdt.launching.SocketUtil (to avoid a dependency to JDT just because of this). * Slightly improved with close() missing in JDT. And throws exception instead of returning -1. * @@ -238,20 +241,11 @@ public void testMultipleMessages() throws URISyntaxException, IOException, Inter * @throws IllegalStateException if unable to find a free port */ private static int findFreePort() { - ServerSocket socket = null; - try { - socket = new ServerSocket(0); - socket.setReuseAddress(true); - return socket.getLocalPort(); - } catch (IOException ignored) { - } finally { - if (socket != null) { - try { - socket.close(); - } catch (IOException ignored) { - } + try (ServerSocket socket = new ServerSocket(0)) { + socket.setReuseAddress(true); + return socket.getLocalPort(); + } catch (IOException ignored) { } - } throw new IllegalStateException("Could not find a free TCP/IP port to start embedded SocketIO Server on"); } diff --git a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/WebSocketTransportTest.java b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/WebSocketTransportTest.java index b01a3296..328545db 100644 --- a/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/WebSocketTransportTest.java +++ b/netty-socketio-core/src/test/java/com/corundumstudio/socketio/transport/WebSocketTransportTest.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2012-2025 Nikita Koksharov + * Copyright (c) 2025 The Socketio4j Project + * Parent project : Copyright (c) 2012-2025 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/netty-socketio-core/src/test/resources/hazelcast-test-config.xml b/netty-socketio-core/src/test/resources/hazelcast-test-config.xml index 7847cc34..6d521312 100644 --- a/netty-socketio-core/src/test/resources/hazelcast-test-config.xml +++ b/netty-socketio-core/src/test/resources/hazelcast-test-config.xml @@ -1,7 +1,8 @@