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 {
4848 }
4949 }
5050
51- private [this ] val taskContext : InheritableThreadLocal [TaskContext ] =
52- new InheritableThreadLocal [TaskContext ]
51+ private [this ] val taskContext : ThreadLocal [TaskContext ] = new ThreadLocal [TaskContext ]
5352
5453 // Note: protected[spark] instead of private[spark] to prevent the following two from
5554 // 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 {
234234 assert(threadTestValue === originalTestValue)
235235 }
236236
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-
257237 /**
258238 * Improve the stack trace of an error thrown from within a thread.
259239 * 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 {
577577 val parFiles = partFiles.par
578578 val pool = ThreadUtils .newForkJoinPool(" readingParquetFooters" , 8 )
579579 parFiles.tasksupport = new ForkJoinTaskSupport (pool)
580+ val tc = TaskContext .get()
580581 try {
581582 parFiles.flatMap { currentFile =>
583+ TaskContext .setTaskContext(tc)
582584 try {
583585 // Skips row group information since we only need the schema.
584586 // ParquetFileReader.readFooter throws RuntimeException, instead of IOException,
You can’t perform that action at this time.
0 commit comments