@@ -171,8 +171,7 @@ private static String getChannelName(final SocketChannel channel) {
171171 public static void threadDump () throws IOException {
172172 // Create a timestamp with milliseconds for the file name
173173 String timestamp = new SimpleDateFormat ("yyyyMMdd_HHmmss_SSS" ).format (new Date ());
174- String fileName = "/app/thread_dump_" + timestamp + ".txt" ;
175- String threadDumpStr = "" ;
174+ String fileName = "/tmp/thread_dump_" + timestamp + ".txt" ;
176175
177176 // Create a PrintWriter to write the thread dump to a file
178177 try (PrintWriter writer = new PrintWriter (new FileWriter (fileName ))) {
@@ -185,15 +184,16 @@ public static void threadDump() throws IOException {
185184
186185 // Write the thread information to the file
187186 for (ThreadInfo threadInfo : threadInfos ) {
188- threadDumpStr += "Thread ID: " + threadInfo .getThreadId () + " Name: " + threadInfo .getThreadName () + " \n " ;
189- threadDumpStr += "Thread State: " + threadInfo .getThreadState () + " \n " ;
187+ writer . println ( "Thread ID: " + threadInfo .getThreadId () + " Name: " + threadInfo .getThreadName ()) ;
188+ writer . println ( "Thread State: " + threadInfo .getThreadState ()) ;
190189 StackTraceElement [] stackTrace = threadInfo .getStackTrace ();
191190 for (StackTraceElement stackTraceElement : stackTrace ) {
192- threadDumpStr += "\t " + stackTraceElement + " \n " ;
191+ writer . println ( "\t " + stackTraceElement ) ;
193192 }
193+ writer .println ();
194194 }
195195 }
196196
197- LOG .info ( threadDumpStr );
197+ LOG .infof ( "Thread dump written to file: %s" , fileName );
198198 }
199199}
0 commit comments