Procházet zdrojové kódy

[livy] Fix creating a session

This fixes the "routeBasePath requires an active request to determine
the servlet path" error. Not sure when this broke, but futures need
to be created inside a AsyncResult in order to pass in the request
appropriately.
Erick Tryzelaar před 10 roky
rodič
revize
e7e7e8b

+ 12 - 9
apps/spark/java/livy-server/src/main/scala/com/cloudera/hue/livy/server/sessions/SessionServlet.scala

@@ -67,17 +67,20 @@ class SessionServlet(sessionManager: SessionManager)
 
   post("/") {
     val createSessionRequest = parsedBody.extract[CreateSessionRequest]
-    val sessionFuture = sessionManager.createSession(createSessionRequest.lang, createSessionRequest.proxyUser)
 
-    val rep = sessionFuture.map { case session =>
-      Created(session,
-        headers = Map(
-          "Location" -> url(getSession, "sessionId" -> session.id.toString)
-        )
-      )
-    }
+    new AsyncResult {
+      val is = {
+        val sessionFuture = sessionManager.createSession(createSessionRequest.lang, createSessionRequest.proxyUser)
 
-    new AsyncResult { val is = rep }
+        sessionFuture.map { case session =>
+          Created(session,
+            headers = Map(
+              "Location" -> url(getSession, "sessionId" -> session.id.toString)
+            )
+          )
+        }
+      }
+    }
   }
 
   post("/:sessionId/callback") {