From 4cee47df13348b6a3daedc5215d0cec0f98c83ee Mon Sep 17 00:00:00 2001 From: Asif Khatri <123077165+askhatri@users.noreply.github.com> Date: Fri, 18 Aug 2023 17:23:06 +0530 Subject: [PATCH] [LIVY-986][SERVER] Adding null pointer check for SessionInfo (#412) We need to add a null check for SessionInfo in InteractiveSessionServlet.scala to avoid an exception that might occur during a Livy upgrade. --- .../InteractiveSessionServlet.scala | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/server/src/main/scala/org/apache/livy/server/interactive/InteractiveSessionServlet.scala b/server/src/main/scala/org/apache/livy/server/interactive/InteractiveSessionServlet.scala index 239936f3b..a30f2a418 100644 --- a/server/src/main/scala/org/apache/livy/server/interactive/InteractiveSessionServlet.scala +++ b/server/src/main/scala/org/apache/livy/server/interactive/InteractiveSessionServlet.scala @@ -92,14 +92,34 @@ class InteractiveSessionServlet( Nil } + val conf = if (session.conf != null) { + session.conf.asJava + } else null + + val archives = if (session.archives != null) { + session.archives.asJava + } else null + + val jars = if (session.jars != null) { + session.jars.asJava + } else null + + val pyFiles = if (session.pyFiles != null) { + session.pyFiles.asJava + } else null + + val files = if (session.files != null) { + session.files.asJava + } else null + new SessionInfo(session.id, session.name.orNull, session.appId.orNull, session.owner, session.state.toString, session.kind.toString, session.appInfo.asJavaMap, logs.asJava, session.proxyUser.orNull, session.driverMemory.orNull, session.driverCores.getOrElse(0), session.executorMemory.orNull, - session.executorCores.getOrElse(0), session.conf.asJava, session.archives.asJava, - session.files.asJava, session.heartbeatTimeoutS, session.jars.asJava, - session.numExecutors.getOrElse(0), session.proxyUser.orNull, session.pyFiles.asJava, + session.executorCores.getOrElse(0), conf, archives, + files, session.heartbeatTimeoutS, jars, + session.numExecutors.getOrElse(0), session.proxyUser.orNull, pyFiles, session.queue.orNull) }