o-shevchenko commented on a change in pull request #230: [WIP][LIVY-664][Server] Spark application still running when Livy session creating was rejected URL: https://github.com/apache/incubator-livy/pull/230#discussion_r323738822
########## File path: server/src/main/scala/org/apache/livy/server/SessionServlet.scala ########## @@ -131,6 +131,11 @@ abstract class SessionServlet[S <: Session, R <: RecoveryMetadata]( if (tooManySessions) { BadRequest(ResponseMessage("Rejected, too many sessions are being created!")) } else { + // LIVY-664: Check if name is duplicated before create a session + val newSessionName = sessionName(request) + if (newSessionName.isDefined && sessionManager.get(newSessionName.get).isDefined) { Review comment: perhaps, better to add `exists` (or `contains` if you want) methods to `SessionManager`: ``` def exists(id: Int): Boolean = sessions.contains(id) def exists(sessionName: String): Boolean = sessionsByName.contains(sessionName) ``` And use it in the following way: ``` sessionManager.exists(newSessionName.get) ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services