@@ -1143,24 +1143,25 @@ private Class findClass(String name) {
11431143 }
11441144
11451145 private File createTempDir (String dir ) {
1146+ File file = null ;
1147+
11461148 // try Utils.createTempDir()
1147- try {
1148- return (File ) Utils .class .getMethod (
1149- "createTempDir" ,
1150- new Class []{String .class , String .class })
1151- .invoke (null , new Object []{dir , "spark" });
1152- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e ) {
1153- // fallback to old method
1154- try {
1155- return (File ) Utils .class .getMethod (
1156- "createTempDir" ,
1157- new Class []{String .class })
1158- .invoke (null , new Object []{dir });
1159- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e1 ) {
1160- logger .error (e1 .getMessage (), e1 );
1161- return null ;
1162- }
1163- }
1149+ file = (File ) Utils .invokeStaticMethod (
1150+ Utils .findClass ("org.apache.spark.util.Utils" ),
1151+ "createTempDir" ,
1152+ new Class []{String .class , String .class },
1153+ new Object []{dir , "spark" });
1154+
1155+ // fallback to old method
1156+ if (file == null ) {
1157+ file = (File ) Utils .invokeStaticMethod (
1158+ Utils .findClass ("org.apache.spark.util.Utils" ),
1159+ "createTempDir" ,
1160+ new Class []{String .class },
1161+ new Object []{dir });
1162+ }
1163+
1164+ return file ;
11641165 }
11651166
11661167 private HttpServer createHttpServer (File outputDir ) {
0 commit comments