From d47a2dfe8937dcd9cab27d2d6de8e1f390aa1188 Mon Sep 17 00:00:00 2001
From: gsd <mr.little.cat.ru@gmail.com>
Date: Sun, 26 Feb 2023 11:05:59 +0300
Subject: [PATCH] =?UTF-8?q?=D0=B5=D0=B1=D0=BA=D0=B0=20=D1=81=20=D0=BF?=
 =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=BA=D0=B0=D0=BC=D0=B8=20=D0=B8=20=D1=83?=
 =?UTF-8?q?=D1=82=D0=B5=D1=87=D0=BA=D0=BE=D0=B9=203?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../java/app/entities/server/BaseServer.java  | 30 ++++++++++++-------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/main/java/app/entities/server/BaseServer.java b/src/main/java/app/entities/server/BaseServer.java
index 37d58bc..ab54e97 100644
--- a/src/main/java/app/entities/server/BaseServer.java
+++ b/src/main/java/app/entities/server/BaseServer.java
@@ -17,25 +17,35 @@ public abstract class BaseServer {
     private ExecutorService executorServices_query;
     @JsonIgnore
     private ExecutorService executorServices_rcon;
+    @JsonIgnore
+    private SourceRconClient sourceRconClient;
+    @JsonIgnore
+    private SourceQueryClient sourceQueryClient;
 
     @JsonIgnore
     public SourceRconClient GetSourceRconClient() {
         if (executorServices_rcon == null) executorServices_rcon = Executors.newCachedThreadPool();
-        SourceRconOptions options = SourceRconOptions.builder()
-                .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH)
-                .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_rcon)
-                .build();
-        return new SourceRconClient(options);
+        if (sourceRconClient == null) {
+            SourceRconOptions options = SourceRconOptions.builder()
+                    .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH)
+                    .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_rcon)
+                    .build();
+            sourceRconClient = new SourceRconClient(options);
+        }
+        return sourceRconClient;
     }
 
 
     @JsonIgnore
     public SourceQueryClient GetSourceQueryClient() {
         if (executorServices_query == null) executorServices_query = Executors.newCachedThreadPool();
-        SourceQueryOptions options = SourceQueryOptions.builder()
-                .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH)
-                .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_query)
-                .build();
-        return new SourceQueryClient(options);
+        if (sourceQueryClient == null) {
+            SourceQueryOptions options = SourceQueryOptions.builder()
+                    .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH)
+                    .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_query)
+                    .build();
+            sourceQueryClient = new SourceQueryClient(options);
+        }
+        return sourceQueryClient;
     }
 }