@@ -22,6 +22,7 @@ import java.io.{FileWriter, PrintWriter, File}
2222import org .apache .spark .SharedSparkContext
2323import org .apache .spark .deploy .SparkHadoopUtil
2424import org .apache .spark .scheduler .{SparkListenerTaskEnd , SparkListener }
25+ import org .apache .spark .util .Utils
2526
2627import org .scalatest .FunSuite
2728import org .scalatest .matchers .ShouldMatchers
@@ -108,26 +109,21 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext with Shou
108109 }
109110
110111 test(" exceptions while getting IO thread statistics should not fail tasks / jobs (SPARK-8062)" ) {
111- // For some reason, the following code needs to be called in order for this regression test to
112- // fail and reproduce the bug. The fact that this is necessary suggests that there may be other
113- // bugs in our InputOutputMetrics code; SPARK-8086 tracks progress towards investigating this
114- // issue, since fixing it is out of scope for SPARK-8062.
115- val fs = FileSystem .getLocal(new Configuration ())
116- val outPath = new Path (fs.getWorkingDirectory, " outdir" )
117- SparkHadoopUtil .get.getFSBytesWrittenOnThreadCallback(outPath, fs.getConf)
112+ val tempDir = Utils .createTempDir()
113+ val outPath = new File (tempDir, " outfile" )
118114
119115 // Intentionally call this method with a null scheme, which will store an entry for a FileSystem
120116 // with a null scheme into Hadoop's global `FileSystem.statisticsTable`.
121117 FileSystem .getStatistics(null , classOf [FileSystem ])
122118
123119 // Prior to fixing SPARK-8062, this would fail with a NullPointerException in
124120 // SparkHadoopUtil.getFileSystemThreadStatistics
125- val rdd = sc.parallelize(Array (" a" , " b" , " c" , " d" ), 2 )
126121 try {
122+ val rdd = sc.parallelize(Array (" a" , " b" , " c" , " d" ), 2 )
127123 rdd.saveAsTextFile(outPath.toString)
128124 sc.textFile(outPath.toString).count()
129125 } finally {
130- fs.delete(outPath, true )
126+ Utils .deleteRecursively(tempDir )
131127 }
132128 }
133129}
0 commit comments