File tree Expand file tree Collapse file tree 3 files changed +3
-22
lines changed
main/scala/org/apache/spark
test/scala/org/apache/spark
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet Expand file tree Collapse file tree 3 files changed +3
-22
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,7 @@ object TaskContext {
48
48
}
49
49
}
50
50
51
- private [this ] val taskContext : InheritableThreadLocal [TaskContext ] =
52
- new InheritableThreadLocal [TaskContext ]
51
+ private [this ] val taskContext : ThreadLocal [TaskContext ] = new ThreadLocal [TaskContext ]
53
52
54
53
// Note: protected[spark] instead of private[spark] to prevent the following two from
55
54
// showing up in JavaDoc.
Original file line number Diff line number Diff line change @@ -234,26 +234,6 @@ class ThreadingSuite extends SparkFunSuite with LocalSparkContext with Logging {
234
234
assert(threadTestValue === originalTestValue)
235
235
}
236
236
237
- test(" taskContext accessed from a thread pool" ) {
238
- TaskContext .setTaskContext(TaskContext .empty())
239
- assert(TaskContext .get() != null , " taskContext should have been defined" )
240
- var throwable : Option [Throwable ] = None
241
- val thread = new Thread () {
242
- override def run () {
243
- try {
244
- assert(TaskContext .get() != null , " taskContext should have been inherited" )
245
- } catch {
246
- case t : Throwable =>
247
- throwable = Option (t)
248
- }
249
- }
250
- }
251
- thread.start()
252
- thread.join()
253
- throwable.foreach { t => throw improveStackTrace(t) }
254
- TaskContext .unset()
255
- }
256
-
257
237
/**
258
238
* Improve the stack trace of an error thrown from within a thread.
259
239
* Otherwise it's difficult to tell which line in the test the error came from.
Original file line number Diff line number Diff line change @@ -577,8 +577,10 @@ object ParquetFileFormat extends Logging {
577
577
val parFiles = partFiles.par
578
578
val pool = ThreadUtils .newForkJoinPool(" readingParquetFooters" , 8 )
579
579
parFiles.tasksupport = new ForkJoinTaskSupport (pool)
580
+ val tc = TaskContext .get()
580
581
try {
581
582
parFiles.flatMap { currentFile =>
583
+ TaskContext .setTaskContext(tc)
582
584
try {
583
585
// Skips row group information since we only need the schema.
584
586
// ParquetFileReader.readFooter throws RuntimeException, instead of IOException,
You can’t perform that action at this time.
0 commit comments