This is an automated email from the ASF dual-hosted git repository.

rpuch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 4e9f914429 IGNITE-23711 Add missing synchronization in NettyServer 
(#4749)
4e9f914429 is described below

commit 4e9f9144293cb96351e3e880ba7df970f980a4b9
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Thu Nov 21 10:55:14 2024 +0400

    IGNITE-23711 Add missing synchronization in NettyServer (#4749)
---
 .../ignite/internal/network/netty/NettyServer.java     | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git 
a/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
 
b/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
index 8978c9143b..abcecbcec3 100644
--- 
a/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
+++ 
b/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
@@ -42,6 +42,7 @@ import 
org.apache.ignite.internal.network.serialization.PerSessionSerializationS
 import org.apache.ignite.internal.network.serialization.SerializationService;
 import org.apache.ignite.internal.network.ssl.SslContextProvider;
 import org.apache.ignite.internal.util.CompletableFutures;
+import org.apache.ignite.lang.ErrorGroups.Common;
 import org.apache.ignite.lang.IgniteException;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.annotations.TestOnly;
@@ -113,11 +114,11 @@ public class NettyServer {
     public CompletableFuture<Void> start() {
         synchronized (startStopLock) {
             if (stopped) {
-                throw new IgniteInternalException("Attempted to start an 
already stopped server");
+                throw new IgniteInternalException(Common.INTERNAL_ERR, 
"Attempted to start an already stopped server");
             }
 
             if (serverStartFuture != null) {
-                throw new IgniteInternalException("Attempted to start an 
already started server");
+                throw new IgniteInternalException(Common.INTERNAL_ERR, 
"Attempted to start an already started server");
             }
 
             ServerBootstrap bootstrap = 
bootstrapFactory.createServerBootstrap();
@@ -210,14 +211,15 @@ public class NettyServer {
                 return nullCompletedFuture();
             }
 
-            var serverCloseFuture0 = serverCloseFuture;
-
             return serverStartFuture.handle((unused, throwable) -> {
-                if (channel != null) {
-                    channel.close();
-                }
+                synchronized (startStopLock) {
+                    ServerChannel localChannel = channel;
+                    if (localChannel != null) {
+                        localChannel.close();
+                    }
 
-                return serverCloseFuture0 == null ? 
CompletableFutures.<Void>nullCompletedFuture() : serverCloseFuture0;
+                    return serverCloseFuture == null ? 
CompletableFutures.<Void>nullCompletedFuture() : serverCloseFuture;
+                }
             }).thenCompose(Function.identity());
         }
     }

Reply via email to