|
13 | 13 | // limitations under the License.
|
14 | 14 | package com.google.devtools.build.lib.util;
|
15 | 15 |
|
| 16 | +import static java.nio.charset.StandardCharsets.UTF_8; |
16 | 17 | import static java.util.stream.Collectors.toCollection;
|
17 | 18 |
|
18 | 19 | import com.google.common.annotations.VisibleForTesting;
|
19 | 20 | import com.google.common.base.Joiner;
|
20 | 21 | import com.google.common.flogger.GoogleLogger;
|
21 | 22 | import com.google.devtools.build.lib.bugreport.BugReporter;
|
| 23 | +import java.io.ByteArrayOutputStream; |
| 24 | +import java.io.IOException; |
22 | 25 | import java.util.ArrayList;
|
23 | 26 | import java.util.Arrays;
|
24 | 27 | import java.util.Comparator;
|
@@ -46,8 +49,7 @@ public class ThreadUtils {
|
46 | 49 | MAP_WITH_ARRAY_LIST_VALUES_COLLECTOR =
|
47 | 50 | Collectors.groupingBy(StackTraceAndState::new, toCollection(ArrayList::new));
|
48 | 51 |
|
49 |
| - private ThreadUtils() { |
50 |
| - } |
| 52 | + private ThreadUtils() {} |
51 | 53 |
|
52 | 54 | /** Write a thread dump to the blaze.INFO log if interrupt took too long. */
|
53 | 55 | public static synchronized void warnAboutSlowInterrupt(
|
@@ -87,6 +89,16 @@ static synchronized void warnAboutSlowInterrupt(
|
87 | 89 | makeString(stackTraceAndState.trace));
|
88 | 90 | });
|
89 | 91 |
|
| 92 | + try { |
| 93 | + var out = new ByteArrayOutputStream(); |
| 94 | + ThreadDumper.dumpThreads(out); |
| 95 | + logger.atWarning().log( |
| 96 | + "Dumping additional thread state using ThreadDumper:\n%s", |
| 97 | + new String(out.toByteArray(), UTF_8)); |
| 98 | + } catch (IOException e) { |
| 99 | + logger.atWarning().withCause(e).log("Failed to dump threads with ThreadDumper."); |
| 100 | + } |
| 101 | + |
90 | 102 | SlowInterruptInnerException inner =
|
91 | 103 | new SlowInterruptInnerException(
|
92 | 104 | Joiner.on(' ')
|
|
0 commit comments