Skip to content

Commit 90ec643

Browse files
author
Andrew Or
committed
[HOT FIX] [YARN] Check whether /lib exists before listing its files
This is caused by a975dc3 Author: Andrew Or <[email protected]> Closes #3589 from andrewor14/yarn-hot-fix and squashes the following commits: a4fad5f [Andrew Or] Check whether lib directory exists before listing its files
1 parent 692f493 commit 90ec643

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

yarn/common/src/main/scala/org/apache/spark/deploy/yarn/ClientBase.scala

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,21 @@ private[spark] trait ClientBase extends Logging {
243243
val libsURI = new URI(libsDir)
244244
val jarLinks = ListBuffer.empty[String]
245245
if (libsURI.getScheme != LOCAL_SCHEME) {
246-
val localURI = getQualifiedLocalPath(libsURI).toUri()
247-
val jars = FileSystem.get(localURI, hadoopConf).listFiles(new Path(localURI.getPath), false)
248-
while (jars.hasNext) {
249-
val jar = jars.next()
250-
val name = jar.getPath.getName
251-
if (name.startsWith("datanucleus-")) {
252-
// copy to remote and add to classpath
253-
val src = jar.getPath
254-
val destPath = copyFileToRemote(dst, src, replication)
255-
distCacheMgr.addResource(fs, hadoopConf, destPath,
256-
localResources, LocalResourceType.FILE, name, statCache)
257-
jarLinks += name
246+
val localPath = getQualifiedLocalPath(libsURI)
247+
val localFs = FileSystem.get(localPath.toUri, hadoopConf)
248+
if (localFs.exists(localPath)) {
249+
val jars = localFs.listFiles(localPath, /* recursive */ false)
250+
while (jars.hasNext) {
251+
val jar = jars.next()
252+
val name = jar.getPath.getName
253+
if (name.startsWith("datanucleus-")) {
254+
// copy to remote and add to classpath
255+
val src = jar.getPath
256+
val destPath = copyFileToRemote(dst, src, replication)
257+
distCacheMgr.addResource(localFs, hadoopConf, destPath,
258+
localResources, LocalResourceType.FILE, name, statCache)
259+
jarLinks += name
260+
}
258261
}
259262
}
260263
} else {

0 commit comments

Comments
 (0)