File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
main/scala/org/apache/spark/deploy/history
test/scala/org/apache/spark/deploy/history Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -76,9 +76,7 @@ class HistoryServer(
7676 // attempt ID (separated by a slash).
7777 val parts = Option (req.getPathInfo()).getOrElse(" " ).split(" /" )
7878 if (parts.length < 2 ) {
79- res.sendError(HttpServletResponse .SC_BAD_REQUEST ,
80- s " Unexpected path info in request (URI = ${req.getRequestURI()}" )
81- return
79+ res.sendRedirect(" /" )
8280 }
8381
8482 val appId = parts(1 )
Original file line number Diff line number Diff line change @@ -644,6 +644,19 @@ class HistoryServerSuite extends SparkFunSuite with BeforeAndAfter with Matchers
644644 val actualContentType = conn.getContentType
645645 assert(actualContentType === expectedContentType)
646646 }
647+
648+ test(" Redirect to the root page when accessed to /history/" ) {
649+ val port = server.boundPort
650+ val url = new URL (s " http://localhost: $port/history/ " )
651+ val conn = url.openConnection().asInstanceOf [HttpURLConnection ]
652+ conn.setRequestMethod(" GET" )
653+ conn.setUseCaches(false )
654+ conn.setDefaultUseCaches(false )
655+ conn.setInstanceFollowRedirects(false )
656+ conn.connect()
657+ assert(conn.getResponseCode === 302 )
658+ assert(conn.getHeaderField(" Location" ) === s " http://localhost: $port/ " )
659+ }
647660}
648661
649662object HistoryServerSuite {
You can’t perform that action at this time.
0 commit comments