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(
76
76
// attempt ID (separated by a slash).
77
77
val parts = Option (req.getPathInfo()).getOrElse(" " ).split(" /" )
78
78
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(" /" )
82
80
}
83
81
84
82
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
644
644
val actualContentType = conn.getContentType
645
645
assert(actualContentType === expectedContentType)
646
646
}
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
+ }
647
660
}
648
661
649
662
object HistoryServerSuite {
You can’t perform that action at this time.
0 commit comments