Skip to content

Commit 1a64209

Browse files
committed
Review fixes
1 parent 0d45a5b commit 1a64209

File tree

2 files changed

+10
-54
lines changed

2 files changed

+10
-54
lines changed

core/src/test/resources/thread_whitelist

Lines changed: 0 additions & 24 deletions
This file was deleted.

core/src/test/scala/org/apache/spark/SparkFunSuite.scala

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ abstract class SparkFunSuite
3636
with Logging {
3737
// scalastyle:on
3838

39+
val threadWhiteList = Set(
40+
"rpc-client.*", "rpc-server.*", "shuffle-client.*", "shuffle-server.*",
41+
"netty.*", "globalEventExecutor.*", "threadDeathWatcher.*"
42+
)
3943
var beforeAllTestThreadNames: Set[String] = Set.empty
4044

4145
protected override def beforeAll(): Unit = {
42-
saveThreadNames()
46+
beforeAllTestThreadNames = runningThreadNames()
4347
super.beforeAll()
4448
}
4549

@@ -62,14 +66,14 @@ abstract class SparkFunSuite
6266
getTestResourceFile(file).getCanonicalPath
6367
}
6468

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
6771
}
6872

6973
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(_)) }
7377
val remainingThreadNames = whitelistedThreadNames.diff(beforeAllTestThreadNames)
7478
if (!remainingThreadNames.isEmpty) {
7579
val suiteName = this.getClass.getName
@@ -99,27 +103,3 @@ abstract class SparkFunSuite
99103
}
100104

101105
}
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

Comments
 (0)