@@ -36,10 +36,14 @@ abstract class SparkFunSuite
36
36
with Logging {
37
37
// scalastyle:on
38
38
39
+ val threadWhiteList = Set (
40
+ " rpc-client.*" , " rpc-server.*" , " shuffle-client.*" , " shuffle-server.*" ,
41
+ " netty.*" , " globalEventExecutor.*" , " threadDeathWatcher.*"
42
+ )
39
43
var beforeAllTestThreadNames : Set [String ] = Set .empty
40
44
41
45
protected override def beforeAll (): Unit = {
42
- saveThreadNames ()
46
+ beforeAllTestThreadNames = runningThreadNames ()
43
47
super .beforeAll()
44
48
}
45
49
@@ -62,14 +66,14 @@ abstract class SparkFunSuite
62
66
getTestResourceFile(file).getCanonicalPath
63
67
}
64
68
65
- private def saveThreadNames (): Unit = {
66
- beforeAllTestThreadNames = Thread .getAllStackTraces.keySet().map(_.getName).toSet
69
+ private def runningThreadNames (): Set [ String ] = {
70
+ Thread .getAllStackTraces.keySet().map(_.getName).toSet
67
71
}
68
72
69
73
private def printRemainingThreadNames (): Unit = {
70
- val currentThreadNames = Thread .getAllStackTraces.keySet().map(_.getName).toSet
71
- val whitelistedThreadNames = currentThreadNames.
72
- filterNot( s => SparkFunSuite . threadWhiteList.exists(s.matches(_)))
74
+ val currentThreadNames = runningThreadNames()
75
+ val whitelistedThreadNames = currentThreadNames
76
+ . filterNot { s => threadWhiteList.exists(s.matches(_)) }
73
77
val remainingThreadNames = whitelistedThreadNames.diff(beforeAllTestThreadNames)
74
78
if (! remainingThreadNames.isEmpty) {
75
79
val suiteName = this .getClass.getName
@@ -99,27 +103,3 @@ abstract class SparkFunSuite
99
103
}
100
104
101
105
}
102
-
103
- object SparkFunSuite
104
- extends Logging {
105
- val threadWhitelistFileName = " /thread_whitelist"
106
- val threadWhiteList : Set [String ] = try {
107
- val whileListStream = getClass.getResourceAsStream(threadWhitelistFileName)
108
- if (whileListStream == null ) {
109
- logWarning(s " \n\n ===== Could not find global thread whitelist file with " +
110
- s " name $threadWhitelistFileName on classpath' ===== \n " )
111
- Set .empty
112
- } else {
113
- val whiteList = Source .fromInputStream(whileListStream)
114
- .getLines().filterNot(s => s.isEmpty || s.startsWith(" #" )).toSet
115
- logInfo(s " \n\n ===== Global thread whitelist loaded with name " +
116
- s " $threadWhitelistFileName from classpath: ${whiteList.mkString(" , " )}' ===== \n " )
117
- whiteList
118
- }
119
- } catch {
120
- case e : Exception =>
121
- logWarning(s " \n\n ===== Could not read global thread whitelist file with " +
122
- s " name $threadWhitelistFileName from classpath: ${e.getMessage}' ===== \n " )
123
- Set .empty
124
- }
125
- }
0 commit comments