mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-9610 Set TimerQueue thread exclusion for BugJBR9563.java
This commit is contained in:
committed by
jbrbot
parent
25532ba2f9
commit
cb9880fa8c
@@ -37,6 +37,7 @@ import java.util.stream.Collectors;
|
|||||||
@run main BugJBR9563
|
@run main BugJBR9563
|
||||||
*/
|
*/
|
||||||
public class BugJBR9563 {
|
public class BugJBR9563 {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
CountDownLatch windowOpened = new CountDownLatch(1);
|
CountDownLatch windowOpened = new CountDownLatch(1);
|
||||||
AtomicReference<JFrame> frameRef = new AtomicReference<>();
|
AtomicReference<JFrame> frameRef = new AtomicReference<>();
|
||||||
@@ -76,24 +77,31 @@ public class BugJBR9563 {
|
|||||||
Assert(f != null, "Frame is not captured");
|
Assert(f != null, "Frame is not captured");
|
||||||
|
|
||||||
|
|
||||||
Set<String> threadsAfterRendering = getCurrentThreads();
|
Set<String> threadsAfterRendering = getCurrentThreads()
|
||||||
|
.stream()
|
||||||
|
.map(t -> t.threadId() + " " + t.getName())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
System.out.println("Threads after rendering: " + threadsAfterRendering);
|
System.out.println("Threads after rendering: " + threadsAfterRendering);
|
||||||
|
|
||||||
Callable<Boolean> task = () -> {
|
|
||||||
System.out.println("Check threads state...");
|
|
||||||
Set<String> threads = getCurrentThreads();
|
|
||||||
List<String> newThreads = threads.stream().filter(it -> !threadsAfterRendering.contains(it)).toList();
|
|
||||||
|
|
||||||
System.out.println("New threads list: " + newThreads);
|
|
||||||
return newThreads.isEmpty();
|
|
||||||
};
|
|
||||||
|
|
||||||
List<Boolean> results = Collections.synchronizedList(new ArrayList<>());
|
List<Boolean> results = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
System.out.println("Check threads state...");
|
System.out.println("Check threads state...");
|
||||||
Set<String> threads = getCurrentThreads();
|
List<Thread> threads = getCurrentThreads();
|
||||||
List<String> newThreads = threads.stream().filter(it -> !threadsAfterRendering.contains(it)).toList();
|
List<Thread> threadsWoTimerQueue = threads
|
||||||
|
.stream().filter(it -> !it.getName().equals("TimerQueue")).toList();
|
||||||
|
|
||||||
|
Assert(threads.size() - threadsWoTimerQueue.size() <= 1, "More than 1 TimerQueue thread found");
|
||||||
|
|
||||||
|
Set<String> threadIdNames = threadsWoTimerQueue
|
||||||
|
.stream()
|
||||||
|
.map(t -> t.threadId() + " " + t.getName())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
List<String> newThreads = threadIdNames
|
||||||
|
.stream()
|
||||||
|
.filter(it -> !threadsAfterRendering.contains(it))
|
||||||
|
.toList();
|
||||||
|
|
||||||
System.out.println("New threads list: " + newThreads);
|
System.out.println("New threads list: " + newThreads);
|
||||||
|
|
||||||
@@ -117,14 +125,9 @@ public class BugJBR9563 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<String> getCurrentThreads() {
|
private static List<Thread> getCurrentThreads() {
|
||||||
Map<Thread, StackTraceElement[]> allThreads = Thread.getAllStackTraces();
|
Map<Thread, StackTraceElement[]> threadsMap = Thread.getAllStackTraces();
|
||||||
|
return threadsMap.keySet().stream().toList();
|
||||||
return allThreads
|
|
||||||
.keySet()
|
|
||||||
.stream()
|
|
||||||
.map(t -> t.threadId() + " " + t.getName())
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Assert(boolean condition, String str) {
|
private static void Assert(boolean condition, String str) {
|
||||||
|
|||||||
Reference in New Issue
Block a user