From d6c542eabafd4c1e46e95aa08593e06c8cb0fb87 Mon Sep 17 00:00:00 2001
From: Emily Rivas <emily.rivas@oracle.com>
Date: Fri, 15 Nov 2024 15:46:40 -0500
Subject: [PATCH] COH-31131 .NET: Don't print the whole exception stack trace
 in case of Coherence connection failure

[git-p4: depot-paths = "//dev/main.net/": change = 112431]
---
 src/Coherence/Net/Impl/SafeService.cs | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/Coherence/Net/Impl/SafeService.cs b/src/Coherence/Net/Impl/SafeService.cs
index 3f5bdf6..72db8b6 100644
--- a/src/Coherence/Net/Impl/SafeService.cs
+++ b/src/Coherence/Net/Impl/SafeService.cs
@@ -10,6 +10,7 @@
 using System.Threading;
 
 using Tangosol.IO;
+using Tangosol.Net.Messaging;
 using Tangosol.Run.Xml;
 using Tangosol.Util;
 using Tangosol.Util.Daemon.QueueProcessor.Service;
@@ -993,9 +994,18 @@ protected virtual void StartService(Util.IService service)
             }
             catch (Exception e)
             {
-                CacheFactory.Log("Error while starting service \""
-                                 + ServiceName + "\": " + e,
-                                 CacheFactory.LogLevel.Error);
+                string message = "Error while starting service \"" + ServiceName + "\": ";
+                if (service is RemoteService && e is ConnectionException)
+                {
+                    // COH-30321 - skip printing the stack trace as connection failures are common and the stack trace
+                    // doesn't provide anything useful
+                    CacheFactory.Log(message + e, CacheFactory.LogLevel.Error);
+                }
+                else
+                {
+                    CacheFactory.Log(message + e.StackTrace, CacheFactory.LogLevel.Error);
+                }
+                
                 try
                 {
                     service.Stop();