Skip to content

Commit b6f3b99

Browse files
committed
SPARK-11323 - some more style checking in the rest/ package
1 parent ffb9352 commit b6f3b99

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

yarn/src/history/main/scala/org/apache/spark/deploy/history/yarn/rest/JerseyBinding.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ private[spark] object JerseyBinding extends Logging {
200200
ioe = new FileNotFoundException(
201201
s"Bad $verb request: status code $status against $url; $body")
202202
ioe.initCause(exception)
203+
203204
case _ =>
204205
ioe = new IOException(errorText, exception)
205206

yarn/src/history/main/scala/org/apache/spark/deploy/history/yarn/rest/SpnegoUrlConnector.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import org.apache.spark.Logging
3737
* Based on WebHFDS client code in
3838
* `org.apache.hadoop.hdfs.web.URLConnectionFactory`
3939
*/
40-
private[spark] class SpnegoUrlConnector(connConfigurator: ConnectionConfigurator,
40+
private[spark] class SpnegoUrlConnector(
41+
connConfigurator: ConnectionConfigurator,
4142
delegationToken: DelegationTokenAuthenticatedURL.Token) extends Logging {
4243

4344
val secure = UserGroupInformation.isSecurityEnabled
@@ -48,7 +49,7 @@ private[spark] class SpnegoUrlConnector(connConfigurator: ConnectionConfigurator
4849
if (secure) {
4950
new LoggingKerberosDelegationTokenAuthenticator()
5051
} else {
51-
new PseudoDelegationTokenAuthenticator
52+
new PseudoDelegationTokenAuthenticator()
5253
}
5354

5455
init()
@@ -68,21 +69,21 @@ private[spark] class SpnegoUrlConnector(connConfigurator: ConnectionConfigurator
6869
* @param isSpnego whether the url should be authenticated via SPNEGO
6970
* @return URLConnection
7071
* @throws IOException IO problems
71-
* @throws AuthenticationException authenticaion failure
72+
* @throws AuthenticationException authentication failure
7273
*/
7374

7475
def openConnection(url: URL, isSpnego: Boolean): URLConnection = {
7576
require(connConfigurator != null)
7677
require(url.getPort != 0, "no port")
7778
if (isSpnego) {
7879
logDebug(s"open AuthenticatedURL connection $url")
79-
UserGroupInformation.getCurrentUser.checkTGTAndReloginFromKeytab
80+
UserGroupInformation.getCurrentUser.checkTGTAndReloginFromKeytab()
8081
val authToken = new AuthenticatedURL.Token
8182
val authurl = new AuthenticatedURL(KerberosUgiAuthenticator, connConfigurator)
8283
authurl.openConnection(url, authToken)
8384
} else {
8485
logDebug(s"open URL connection $url")
85-
val connection: URLConnection = url.openConnection
86+
val connection = url.openConnection()
8687
connection match {
8788
case connection1: HttpURLConnection =>
8889
connConfigurator.configure(connection1)
@@ -122,8 +123,8 @@ private[spark] class SpnegoUrlConnector(connConfigurator: ConnectionConfigurator
122123
val conn = callerUGI.doAs(new PrivilegedFunction(
123124
() => {
124125
try {
125-
new AuthenticatedURL(KerberosUgiAuthenticator,
126-
connConfigurator).openConnection(url, authToken)
126+
new AuthenticatedURL(KerberosUgiAuthenticator, connConfigurator)
127+
.openConnection(url, authToken)
127128
} catch {
128129
case ex: AuthenticationException =>
129130
// auth failure
@@ -184,7 +185,7 @@ private[spark] class SpnegoUrlConnector(connConfigurator: ConnectionConfigurator
184185
payload: Array[Byte] = null,
185186
payloadContentType: String = ""): HttpOperationResponse = {
186187
var conn: HttpURLConnection = null
187-
val outcome = new HttpOperationResponse
188+
val outcome = new HttpOperationResponse()
188189
var resultCode = 0
189190
var body: Array[Byte] = null
190191
logDebug(s"$verb $url spnego=$secure")
@@ -285,10 +286,8 @@ private[spark] object SpnegoUrlConnector extends Logging {
285286
/**
286287
* Sets timeout parameters on the given URLConnection.
287288
*
288-
* @param connection
289-
* URLConnection to set
290-
* @param socketTimeout
291-
* the connection and read timeout of the connection.
289+
* @param connection URLConnection to set
290+
* @param socketTimeout the connection and read timeout of the connection.
292291
*/
293292
def setTimeouts(connection: URLConnection, socketTimeout: Int) {
294293
connection.setConnectTimeout(socketTimeout)
@@ -323,7 +322,8 @@ private[spark] object SpnegoUrlConnector extends Logging {
323322
*
324323
* This uses `org.apache.hadoop.security.ssl.SSLFactory` to build an
325324
* SSL factory based on information provided in the Hadoop configuration
326-
* object passed in.
325+
* object passed in, including the hostname verifier specified
326+
* in the configuration options.
327327
*
328328
* @param timeout timeout in millis
329329
* @param conf configuration
@@ -362,7 +362,7 @@ private[spark] object SpnegoUrlConnector extends Logging {
362362
* Uprate error codes 400 and up into exceptions, which are then thrown
363363
*
364364
* 1. 404 is converted to a `FileNotFoundException`
365-
* 2. 401 & 404 to `UnauthorizedRequestException`
365+
* 2. 401 and 404 to `UnauthorizedRequestException`
366366
* 3. All others above 400: `IOException`
367367
* 4. Any error code under 400 is not considered a failure; this function will return normally.
368368
*
@@ -421,9 +421,9 @@ private[spark] object SpnegoUrlConnector extends Logging {
421421
response.responseCode match {
422422
case HttpURLConnection.HTTP_UNAUTHORIZED =>
423423
true
424-
case HttpURLConnection.HTTP_FORBIDDEN if message == ANONYMOUS_REQUESTS_DISALLOWED ||
425-
message.contains(INVALID_SIGNATURE) =>
426-
true
424+
case HttpURLConnection.HTTP_FORBIDDEN
425+
if message == ANONYMOUS_REQUESTS_DISALLOWED || message.contains(INVALID_SIGNATURE) =>
426+
true
427427
case _ =>
428428
false
429429
}

0 commit comments

Comments
 (0)